Skip to content

Commit 19903c5

Browse files
committed
fix: fix issues with setting dir from command
1 parent 5add054 commit 19903c5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lua/neo-tree/command/init.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@ M.execute = function(args)
9797

9898
-- Handle setting directory if requested
9999
local path_changed = false
100-
if args.dir then
100+
if utils.truthy(args.dir) then
101101
if #args.dir > 1 and args.dir:sub(-1) == utils.path_separator then
102102
args.dir = args.dir:sub(1, -2)
103103
end
104104
path_changed = state.path ~= args.dir
105-
state.path = args.dir
105+
else
106+
args.dir = state.path
106107
end
107108

108109
-- Handle reveal logic
@@ -151,7 +152,7 @@ do_show_or_focus = function(args, state, force_navigate)
151152
end
152153
close_other_sources()
153154
local current_win = vim.api.nvim_get_current_win()
154-
manager.navigate(state, state.path, args.reveal_file, function()
155+
manager.navigate(state, args.dir, args.reveal_file, function()
155156
-- navigate changes the window to neo-tree, so just quickly hop back to the original window
156157
vim.api.nvim_set_current_win(current_win)
157158
end)
@@ -162,7 +163,7 @@ do_show_or_focus = function(args, state, force_navigate)
162163
end
163164
if force_navigate or not window_exists then
164165
close_other_sources()
165-
manager.navigate(state, state.path, args.reveal_file)
166+
manager.navigate(state, args.dir, args.reveal_file)
166167
end
167168
end
168169
end

0 commit comments

Comments
 (0)