fix: clear attr_toggle state after formatting
When :LspSCLFormat is used, line numbers and positions change, but the attr_toggle module stores state based on old positions. This caused toggle/expand/collapse to not work after formatting. Now clears the attr_toggle buffer state after formatting so that users can collapse blocks fresh after formatting.
This commit is contained in:
@@ -36,6 +36,11 @@ function M.setup(opts)
|
||||
if opts.lsp and opts.lsp.formatting then
|
||||
vim.api.nvim_buf_create_user_command(b, "LspSCLFormat", function()
|
||||
vim.lsp.buf.format({ name = "scl_lsp" })
|
||||
-- Clear attr_toggle state since line positions may have changed
|
||||
local ok, at = pcall(require, "scl.attr_toggle")
|
||||
if ok then
|
||||
at.clear_buffer_state(vim.api.nvim_get_current_buf())
|
||||
end
|
||||
end, {})
|
||||
end
|
||||
end,
|
||||
@@ -53,6 +58,11 @@ function M.setup(opts)
|
||||
-- Create global format command (works on current buffer)
|
||||
vim.api.nvim_create_user_command("LspSCLFormat", function()
|
||||
vim.lsp.buf.format({ name = "scl_lsp" })
|
||||
-- Clear attr_toggle state since line positions may have changed
|
||||
local ok, at = pcall(require, "scl.attr_toggle")
|
||||
if ok then
|
||||
at.clear_buffer_state(vim.api.nvim_get_current_buf())
|
||||
end
|
||||
end, {})
|
||||
|
||||
-- Start LSP for any existing scl buffers (handles lazy loading case)
|
||||
|
||||
Reference in New Issue
Block a user