fix: switch to an invalid window (#171)

This commit is contained in:
yetone 2024-08-23 18:08:58 +08:00 committed by GitHub
parent 79e9aac1af
commit a3c2a9a0d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -99,6 +99,7 @@ function Sidebar:open()
end
function Sidebar:close()
self:delete_autocmds()
for _, comp in pairs(self) do
if comp and type(comp) == "table" and comp.unmount then
comp:unmount()
@ -827,9 +828,10 @@ function Sidebar:refresh_winids()
local current_idx = Utils.tbl_indexof(winids, current_winid) or 1
if current_idx == #winids then
current_idx = 1
api.nvim_set_current_win(winids[current_idx])
else
current_idx = current_idx + 1
end
if api.nvim_win_is_valid(winids[current_idx]) then
api.nvim_set_current_win(winids[current_idx])
end
end
@ -839,9 +841,10 @@ function Sidebar:refresh_winids()
local current_idx = Utils.tbl_indexof(winids, current_winid) or 1
if current_idx == 1 then
current_idx = #winids
api.nvim_set_current_win(winids[current_idx])
else
current_idx = current_idx - 1
end
if api.nvim_win_is_valid(winids[current_idx]) then
api.nvim_set_current_win(winids[current_idx])
end
end