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:
+7
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user