Skip to content

Commit ded6a85

Browse files
committed
close and abandon all tabs on subsequent setup calls
1 parent e360a32 commit ded6a85

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lua/nvim-tree.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,9 @@ function M.setup(conf)
776776
setup_vim_commands()
777777
end
778778

779-
if M.setup_called and view.is_visible() then
779+
if M.setup_called then
780780
view.close_all_tabs()
781-
view.abandon_current_window()
781+
view.abandon_all_windows()
782782
end
783783

784784
if M.setup_called and core.get_explorer() ~= nil then

lua/nvim-tree/view.lua

+12-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,18 @@ end
326326
function M.abandon_current_window()
327327
local tab = vim.api.nvim_get_current_tabpage()
328328
BUFNR_PER_TAB[tab] = nil
329-
M.View.tabpages[tab].winnr = nil
329+
if M.View.tabpages[tab] then
330+
M.View.tabpages[tab].winnr = nil
331+
end
332+
end
333+
334+
function M.abandon_all_windows()
335+
for tab, _ in pairs(vim.api.nvim_list_tabpages()) do
336+
BUFNR_PER_TAB[tab] = nil
337+
if M.View.tabpages[tab] then
338+
M.View.tabpages[tab].winnr = nil
339+
end
340+
end
330341
end
331342

332343
function M.is_visible(opts)

0 commit comments

Comments
 (0)