Skip to content

Commit aec592b

Browse files
authored
fix: do not auto clean up buffers after session restore, unless opted in (#779)
1 parent f6e4133 commit aec592b

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

lua/neo-tree/defaults.lua

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ local config = {
99
"git_status",
1010
},
1111
add_blank_line_at_top = false, -- Add a blank line at the top of the tree.
12+
auto_clean_after_session_restore = false, -- Automatically clean up broken neo-tree buffers saved in sessions
1213
close_if_last_window = false, -- Close Neo-tree if it is the last window left in the tab
1314
-- popup_border_style is for input and confirmation dialogs.
1415
-- Configurtaion of floating window is done in the individual source sections.

lua/neo-tree/setup/init.lua

+10-7
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,6 @@ local define_events = function()
9494
require("neo-tree.ui.renderer").update_floating_window_layouts()
9595
end,
9696
})
97-
98-
events.subscribe({
99-
event = events.VIM_AFTER_SESSION_LOAD,
100-
handler = function()
101-
require("neo-tree.ui.renderer").clean_invalid_neotree_buffers(true)
102-
end,
103-
})
10497
end
10598

10699
local prior_window_options = {}
@@ -626,6 +619,16 @@ M.merge_config = function(user_config, is_auto_config)
626619
manager.redraw(source_name)
627620
end
628621

622+
if M.config.auto_clean_after_session_restore then
623+
require("neo-tree.ui.renderer").clean_invalid_neotree_buffers(false)
624+
events.subscribe({
625+
event = events.VIM_AFTER_SESSION_LOAD,
626+
handler = function()
627+
require("neo-tree.ui.renderer").clean_invalid_neotree_buffers(true)
628+
end,
629+
})
630+
end
631+
629632
events.subscribe({
630633
event = events.VIM_COLORSCHEME,
631634
handler = highlights.setup,

lua/neo-tree/ui/renderer.lua

-1
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,6 @@ create_window = function(state)
841841
tabnr = state.tabnr,
842842
}
843843
events.fire_event(events.NEO_TREE_WINDOW_BEFORE_OPEN, event_args)
844-
M.clean_invalid_neotree_buffers(false)
845844

846845
if state.current_position == "float" then
847846
state.force_float = nil

0 commit comments

Comments
 (0)