Skip to content

Commit 74dde56

Browse files
committed
fix(#1723): find_file for externally created new file results in folder unable to be opened
1 parent 8cb19bc commit 74dde56

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lua/nvim-tree.lua

+15-15
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,6 @@ end
6969
---@deprecated
7070
M.on_keypress = require("nvim-tree.actions.dispatch").dispatch
7171

72-
function M.toggle(find_file, no_focus, cwd, bang)
73-
if view.is_visible() then
74-
view.close()
75-
else
76-
local previous_buf = vim.api.nvim_get_current_buf()
77-
M.open(cwd)
78-
if _config.update_focused_file.enable or find_file then
79-
find_file(false, previous_buf, bang)
80-
end
81-
if no_focus then
82-
vim.cmd "noautocmd wincmd p"
83-
end
84-
end
85-
end
86-
8772
function M.open(cwd)
8873
cwd = cwd ~= "" and cwd or nil
8974
if view.is_visible() then
@@ -178,6 +163,21 @@ function M.find_file(with_open, bufnr, bang)
178163
find_file(with_open, bufnr, bang)
179164
end
180165

166+
function M.toggle(do_find_file, no_focus, cwd, bang)
167+
if view.is_visible() then
168+
view.close()
169+
else
170+
local previous_buf = vim.api.nvim_get_current_buf()
171+
M.open(cwd)
172+
if _config.update_focused_file.enable or do_find_file then
173+
find_file(false, previous_buf, bang)
174+
end
175+
if no_focus then
176+
vim.cmd "noautocmd wincmd p"
177+
end
178+
end
179+
end
180+
181181
M.resize = view.resize
182182

183183
function M.open_on_directory()

0 commit comments

Comments
 (0)