Skip to content

Commit e801a2d

Browse files
committed
fix(statuscolumn): Changed when options are set
This is to to prevent unexpected errors when lagecy features open new windows. Might be slightly slow.
1 parent 83d15bb commit e801a2d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lua/bars/statuscolumn.lua

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ statuscolumn.detach = function (buffer)
238238
vim.wo[win].statuscolumn = vim.w[win].__statuscolumn[1];
239239
vim.w[win].__statuscolumn = nil;
240240
else
241-
vim.wo[win].statuscolumn = "";
241+
vim.wo[win].statuscolumn = "";
242242
end
243243

244244
vim.w[win].__scID = nil;
@@ -290,16 +290,18 @@ statuscolumn.attach = function (buffer)
290290
goto continue;
291291
end
292292

293-
local scID = statuscolumn.update_id(win);
294-
statuscolumn.state.attached_windows[win] = true;
293+
vim.defer_fn(function ()
294+
local scID = statuscolumn.update_id(win);
295+
statuscolumn.state.attached_windows[win] = true;
295296

296-
vim.w[win].__scID = scID;
297+
vim.w[win].__scID = scID;
297298

298-
vim.w[win].__numberwidth = utils.to_constant(vim.wo[win].numberwidth);
299-
vim.w[win].__statuscolumn = utils.to_constant(vim.wo[win].statuscolumn);
299+
vim.w[win].__numberwidth = utils.to_constant(vim.wo[win].numberwidth);
300+
vim.w[win].__statuscolumn = utils.to_constant(vim.wo[win].statuscolumn);
300301

301-
vim.wo[win].numberwidth = 1;
302-
vim.wo[win].statuscolumn = "%!v:lua.require('bars.statuscolumn').render(" .. buffer .."," .. win ..")";
302+
vim.wo[win].numberwidth = 1;
303+
vim.wo[win].statuscolumn = "%!v:lua.require('bars.statuscolumn').render(" .. buffer .."," .. win ..")";
304+
end, 0)
303305

304306
::continue::
305307
end
@@ -358,7 +360,7 @@ statuscolumn.setup = function (config)
358360
statuscolumn.config = vim.tbl_extend("force", statuscolumn.config, config);
359361
end
360362

361-
for _, window in ipairs(statuscolumn.state.attached_windows) do
363+
for window, _ in pairs(statuscolumn.state.attached_windows) do
362364
vim.w[window].__scID = statuscolumn.update_id(window);
363365
end
364366
end

0 commit comments

Comments
 (0)