The formatter was incorrectly treating multi-line attribute blocks as
assignments, causing AUTHOR/VERSION lines to get weird indentation.
Lines like:
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
Were being processed incorrectly because the attribute block line
contains := but no semicolon, causing the formatter to treat the
next line as a continuation.
Fix by tracking in_attr_block state and skipping assignment detection
for lines inside or exiting attribute blocks.
- 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
- Update AGENTS.md to encourage comments instead of forbidding them
- Add docstrings to all public functions in src/ modules
- Add module headers and function comments to lua/scl/ modules
- Fix formatter to properly indent multi-line IF/ELSIF conditions
- Fix FB call detection to not match IF statements with parentheses
- Add in_condition state to track when inside IF/ELSIF condition (before THEN)
- Use condition_indent for continuation lines in conditions
- Fixes multiline IF/ELSIF conditions being incorrectly indented
- Fix formatter to properly detect when multiline assignment ends
- Add check for line ending with := and ; before checking continuation
- Fixes issue where subsequent lines were incorrectly indented
- Fix formatter to detect continuation lines that don't start with
operators (e.g., #variable AND ... continuation lines)
- All continuation lines now align vertically after :=
- Format multi-line assignments with proper alignment
- Format FB calls in multiline style with parameter alignment
- Auto-expand collapsed attribute blocks before save
- Rename command from LspSCLFormat to SCLFormat
- Condense AGENTS.md and add testing section with reference project
When the formatter automatically collapses attribute blocks, the
original content is lost and cannot be restored by the toggle
module. This broke the attribute expand/collapse functionality.
Changed default from collapseAttributes = true to false.
Users who want collapsing should:
1. Use :LspSCLFormat to format (preserves original content)
2. Then use :SCLCollapseAllAttrBlocks to collapse (stores original)
3. Now toggle/expand works correctly because content is stored
The get_keyword() function was using pattern ^(%w+_%w+) which only
matched up to the second underscore, causing VAR_IN_OUT to be
extracted as VAR_IN. Since VAR_IN is not in VAR_KEYWORDS, the
VAR_IN_OUT block was not being pushed onto the stack.
Fixed by changing the pattern to ^([%w_]+) to capture the entire
keyword including all underscores.
This ensures variables inside VAR_IN_OUT, VAR_CONSTANT, and other
multi-underscore VAR sections are properly indented.
- Multi-line IF conditions: continuation lines at +1 from IF
- END_IF now decreases indent (reverted previous wrong change)
- Track multi-line condition state separately from THEN tracking
- Now matches TIA Portal expected format
- Track when IF has THEN on separate line
- Don't increase indent after IF until THEN is seen
- Increase indent after THEN for content
- Continuation lines in conditions stay at same level as IF
- END_IF stays at same level as content (TIA Portal style)
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.
- Track first line of FB call separately with fb_call_first_line flag
- First line of FB call uses normal indent
- Continuation lines use continuation indent (base + fb_name_length + 2)
- Closing line uses normal indent
- Parameters now align correctly
- Use correct continuation indent formula (base + fb_name_length + 2)
- Fix closing line of FB call to use continuation indent
- Parameters on continuation lines are now aligned
- Re-indent comments to match current block level
- Add FB/function call continuation detection and alignment
- Support both #fbname and "FBName" syntax
- Fix FB call detection to exclude assignment statements
- Continuation lines get +1 indent level
- Default to tabs (not spaces) per TIA Portal standard
- Fix block keyword handling (IF, FOR, WHILE, CASE, REGION, etc.)
- Handle VAR section indentation (variables indented inside VAR)
- Fix IF/ELSIF/ELSE indentation (ELSIF/ELSE at same level as IF)
- Handle CASE labels and nested CASE statements
- Add missing semicolons after END_IF, END_FOR, END_CASE Handle block, etc.
- enders (END_IF, END_REGION, etc.) correctly
- Support compound keywords (END_IF, END_FUNCTION_BLOCK, etc.)