Skip to content

Commit 93491a0

Browse files
authored
fix: delete neo-tree buffers created by :mksession (#748)
1 parent af0e162 commit 93491a0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lua/neo-tree/ui/renderer.lua

+17
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ local default_popup_size = { width = 60, height = "80%" }
1717
local floating_windows = {}
1818
local draw, create_window, create_tree, render_tree
1919

20+
-- clean up neotree buffers created by :mksession
21+
local cleaned_up = false
22+
local clean_neotree_buffers = function()
23+
if cleaned_up then
24+
return
25+
end
26+
27+
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
28+
local bufname = vim.fn.bufname(buf)
29+
if string.match(bufname, "neo%-tree [^ ]+ %[%d+]") then
30+
vim.api.nvim_buf_delete(buf, { force = true })
31+
end
32+
end
33+
cleaned_up = true
34+
end
35+
2036
local resize_monitor_timer = nil
2137
local start_resize_monitor = function()
2238
local interval = M.resize_timer_interval or -1
@@ -813,6 +829,7 @@ create_window = function(state)
813829
tabnr = state.tabnr,
814830
}
815831
events.fire_event(events.NEO_TREE_WINDOW_BEFORE_OPEN, event_args)
832+
clean_neotree_buffers()
816833

817834
if state.current_position == "float" then
818835
state.force_float = nil

0 commit comments

Comments
 (0)