Skip to content

Commit e72bf2b

Browse files
committed
fix: close existing windows when position changed
1 parent d87d06c commit e72bf2b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lua/neo-tree/command/init.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ M.execute = function(args)
6262

6363
-- Now get the correct state
6464
local state
65-
local default_position = nt.config[args.source].window.position
66-
if args.position == "current" or default_position == "current" then
65+
if args.position == "current" then
6766
local winid = vim.api.nvim_get_current_win()
6867
state = manager.get_state(args.source, nil, winid)
6968
else
@@ -88,6 +87,9 @@ M.execute = function(args)
8887
end
8988

9089
-- Handle position override
90+
local default_position = nt.config[args.source].window.position
91+
local current_position = state.current_position or default_position
92+
local position_changed = args.position ~= current_position
9193
state.current_position = args.position
9294

9395
-- Handle setting directory if requested
@@ -110,6 +112,9 @@ M.execute = function(args)
110112

111113
-- All set, now show or focus the window
112114
local force_navigate = path_changed or do_reveal or state.dirty
115+
if position_changed then
116+
manager.close(args.source)
117+
end
113118
if do_reveal then
114119
handle_reveal(args, state)
115120
else

0 commit comments

Comments
 (0)