fix(formatter): Keep END_IF at same indent level as content
Per TIA Portal standard, END_IF stays at the same indent level as the code inside the IF block, rather than decreasing. This matches the reference file Em101Sequence.scl where nested END_IF statements are properly aligned.
This commit is contained in:
@@ -285,7 +285,11 @@ function M.format_document(content, options)
|
|||||||
if_base_level = nil
|
if_base_level = nil
|
||||||
end
|
end
|
||||||
in_fb_call = false -- Reset FB call state
|
in_fb_call = false -- Reset FB call state
|
||||||
|
-- Don't decrease indent for END_IF - it stays at same level as content (per TIA Portal)
|
||||||
|
-- Only decrease for other enders like END_REGION, END_CASE, END_FOR, etc.
|
||||||
|
if kw ~= "END_IF" then
|
||||||
indent_level = math.max(0, indent_level - 1)
|
indent_level = math.max(0, indent_level - 1)
|
||||||
|
end
|
||||||
if needs_semicolon(trimmed) then
|
if needs_semicolon(trimmed) then
|
||||||
formatted_line = formatted_line .. ";"
|
formatted_line = formatted_line .. ";"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user