Skip to content

Commit 2d117bd

Browse files
committed
fix(statusline): Chnaged when statusline is set
fix(winbr): Changed when winbar is set
1 parent 37176bd commit 2d117bd

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

lua/bars/statusline.lua

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,12 @@ statusline.detach = function (buffer)
490490
goto continue;
491491
end
492492

493-
vim.w[win].__slID = nil;
494-
vim.wo[win].statusline = "";
493+
vim.defer_fn(function ()
494+
vim.w[win].__slID = nil;
495+
vim.wo[win].statusline = "";
495496

496-
statusline.state.attached_windows[win] = false;
497+
statusline.state.attached_windows[win] = false;
498+
end, 0);
497499
::continue::
498500
end
499501

@@ -532,11 +534,13 @@ statusline.attach = function (buffer)
532534
goto continue;
533535
end
534536

535-
local slID = statusline.update_id(win);
536-
statusline.state.attached_windows[win] = true;
537+
vim.defer_fn(function ()
538+
local slID = statusline.update_id(win);
539+
statusline.state.attached_windows[win] = true;
537540

538-
vim.w[win].__slID = slID;
539-
vim.wo[win].statusline = "%!v:lua.require('bars.statusline').render(" .. buffer .."," .. win ..")";
541+
vim.w[win].__slID = slID;
542+
vim.wo[win].statusline = "%!v:lua.require('bars.statusline').render(" .. buffer .."," .. win ..")";
543+
end, 0);
540544

541545
::continue::
542546
end

lua/bars/winbar.lua

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -557,13 +557,13 @@ winbar.render = function (buffer, window)
557557
return "";
558558
end
559559

560-
local swID = vim.w[window].__scID;
560+
local wbID = vim.w[window].__scID;
561561

562-
if not swID then
562+
if not wbID then
563563
return "";
564564
end
565565

566-
local config = winbar.config[swID];
566+
local config = winbar.config[wbID];
567567

568568
if type(config) ~= "table" then
569569
return "";
@@ -594,11 +594,13 @@ winbar.detach = function (buffer)
594594
local windows = vim.fn.win_findbuf(buffer)
595595

596596
for _, win in ipairs(windows) do
597-
winbar.state.attached_windows[win] = false;
598-
vim.wo[win].winbar = vim.w[win].__winbar and vim.w[win].__winbar[1] or "";
597+
vim.defer_fn(function ()
598+
winbar.state.attached_windows[win] = false;
599+
vim.wo[win].winbar = vim.w[win].__winbar and vim.w[win].__winbar[1] or "";
599600

600-
vim.w[win].__swID = nil;
601-
vim.w[win].__winbar = nil;
601+
vim.w[win].__wbID = nil;
602+
vim.w[win].__winbar = nil;
603+
end, 0);
602604
end
603605

604606
---|fE
@@ -646,13 +648,15 @@ winbar.attach = function (buffer)
646648
goto continue;
647649
end
648650

649-
local swID = winbar.update_id(win);
650-
winbar.state.attached_windows[win] = true;
651+
vim.defer_fn(function ()
652+
local wbID = winbar.update_id(win);
653+
winbar.state.attached_windows[win] = true;
651654

652-
vim.w[win].__swID = swID;
655+
vim.w[win].__wbID = wbID;
653656

654-
vim.w[win].__winbar = utils.to_constant(vim.wo[win].winbar);
655-
vim.wo[win].winbar = "%!v:lua.require('bars.winbar').render(" .. buffer .."," .. win ..")";
657+
vim.w[win].__winbar = utils.to_constant(vim.wo[win].winbar);
658+
vim.wo[win].winbar = "%!v:lua.require('bars.winbar').render(" .. buffer .."," .. win ..")";
659+
end, 0);
656660

657661
::continue::
658662
end
@@ -712,7 +716,7 @@ winbar.setup = function (config)
712716
end
713717

714718
for window, _ in pairs(winbar.state.attached_windows) do
715-
vim.w[window].__swID = winbar.update_id(window);
719+
vim.w[window].__wbID = winbar.update_id(window);
716720
end
717721
end
718722

0 commit comments

Comments
 (0)