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
This commit is contained in:
2026-02-19 11:24:08 +01:00
parent 3d9d1599b9
commit ae75108f32
+7 -2
View File
@@ -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)