Skip to content

Commit 34ee471

Browse files
committed
fix(statusline): Calling statusline.toggle() no longer toggles it globally(when the cached value is "" or nil)
Loop over the windows and attach to the windows again after the statusline is reset. See: neovim/neovim#32805 (comment)
1 parent 208e0b8 commit 34ee471

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lua/bars/statusline.lua

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,16 @@ statusline.detach = function (window)
582582
end
583583

584584
statusline.state.attached_windows[window] = false;
585+
586+
if _sl == "" or _sl == nil then
587+
--- BUG, `set statusline&` resets the statusline
588+
--- globally.
589+
---
590+
--- So, we reattach to all the other windows.
591+
for _, win in ipairs(vim.api.nvim_list_wins()) do
592+
statusline.attach(win);
593+
end
594+
end
585595
end);
586596

587597
---|fE
@@ -621,6 +631,8 @@ end
621631

622632
--- Attaches the statusline module to the windows
623633
--- of a buffer.
634+
---@param window integer
635+
---@param force? boolean
624636
statusline.attach = function (window, force)
625637
---|fS
626638

@@ -683,7 +695,7 @@ statusline.enable = function (window)
683695
return;
684696
end
685697

686-
statusline.attach(window);
698+
statusline.attach(window, true);
687699
end
688700

689701
--- Enables *all* attached windows.

0 commit comments

Comments
 (0)