From ae75108f32f0aabad1f6a66a4193dec47895fc6b Mon Sep 17 00:00:00 2001 From: Lazar Bulovan Date: Thu, 19 Feb 2026 11:24:08 +0100 Subject: [PATCH] fix(formatter): disable automatic attribute collapsing by default 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 --- src/formatter.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/formatter.lua b/src/formatter.lua index 77cde74..78bc3fb 100644 --- a/src/formatter.lua +++ b/src/formatter.lua @@ -98,9 +98,12 @@ function M.format_document(content, options) local indent_char = use_spaces and string.rep(" ", indent_size) or "\t" -- Attribute block collapsing options + -- NOTE: Disabled by default to preserve compatibility with attr_toggle. + -- When formatter collapses blocks, the original content is lost. + -- Use :SCLCollapseAllAttrBlocks after formatting instead. local collapse_attributes = options.collapseAttributes if collapse_attributes == nil then - collapse_attributes = true -- Default: enabled + collapse_attributes = false -- Default: disabled to preserve toggle functionality end -- User can provide custom patterns or extend defaults @@ -531,7 +534,9 @@ function M.get_formatting_options() trimTrailingWhitespace = true, insertFinalNewline = true, trimFinalNewlines = true, - collapseAttributes = true, -- Collapse variable attribute blocks to {...} + collapseAttributes = false, -- Disabled by default to preserve toggle functionality + -- Set to true to enable automatic collapsing during formatting: + -- collapseAttributes = true, -- collapsePatterns = { ... }, -- Override default collapse patterns -- extendCollapsePatterns = { ... }, -- Extend default patterns with custom ones -- collapseVariableRules = { -- Per-variable collapse rules (highest priority)