fix: Attribute block expand/collapse, TIME literal diagnostics, and formatter bugs

- SCLFormat: Remove clear_buffer_state() call that was preventing
       expand after formatting (attr_toggle state now preserved)
     - Diagnostics: Fix false 'Undefined variable' for IEC literals
       like T#2s, D#1d, S5T#1s (TIME, DATE, S5TIME types)
     - Formatter: Fix block comments (* ... *) being misidentified as
       FB calls in VAR_IN_OUT/VAR_INPUT/VAR_OUTPUT sections
     - Formatter: Fix array-based FB calls like instTimers[idx].TON()
       not being properly formatted with aligned parameters
This commit is contained in:
2026-02-24 15:27:58 +01:00
parent 37f8d475f0
commit 0880df4ef5
2 changed files with 31 additions and 4 deletions
+12 -1
View File
@@ -95,11 +95,22 @@ function M.validate_diagnostics(content, workspace_types, root_dir)
var_section_start = nil
end
-- Check if a hash-prefixed match is part of an IEC literal (TIME, S5TIME, etc.)
local function is_iec_literal_at(line, match_start)
if not line or not match_start then return false end
if match_start <= 1 then return false end
local prefix = line:sub(match_start - 1, match_start - 1):upper()
return prefix == "T" or prefix == "D" or prefix == "S"
end
if not in_var_section then
local hash_vars = {}
for var in line:gmatch("#[%w_]+") do
local var_name = var:sub(2)
hash_vars[var_name] = true
local match_start = line:find(var, 1, true)
if not is_iec_literal_at(line, match_start) then
hash_vars[var_name] = true
end
end
for var_name, _ in pairs(hash_vars) do