From 26927332ca38a374df476e5f0aff6a34c73a55b8 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 5 Nov 2022 15:12:01 +1100 Subject: [PATCH 1/2] fix(#1723): find_file for externally created new file results in folder unable to be opened --- lua/nvim-tree/actions/finders/find-file.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree/actions/finders/find-file.lua b/lua/nvim-tree/actions/finders/find-file.lua index df55c1551f2..f2556a6c3d9 100644 --- a/lua/nvim-tree/actions/finders/find-file.lua +++ b/lua/nvim-tree/actions/finders/find-file.lua @@ -16,15 +16,16 @@ function M.fn(fname) if running[fname] or not core.get_explorer() then return end - running[fname] = true - local ps = log.profile_start("find file %s", fname) -- always match against the real path local fname_real = uv.fs_realpath(fname) if not fname_real then return end + running[fname] = true + + local ps = log.profile_start("find file %s", fname) local line = core.get_nodes_starting_line() local absolute_paths_searched = {} From 0feab00ad28d5e47c61003c8ac93a586c48433c9 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sat, 5 Nov 2022 16:30:10 +1100 Subject: [PATCH 2/2] fix(#1723): find_file for externally created new file results in folder unable to be opened --- lua/nvim-tree/actions/finders/find-file.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/nvim-tree/actions/finders/find-file.lua b/lua/nvim-tree/actions/finders/find-file.lua index f2556a6c3d9..87a4d0b4318 100644 --- a/lua/nvim-tree/actions/finders/find-file.lua +++ b/lua/nvim-tree/actions/finders/find-file.lua @@ -26,11 +26,13 @@ function M.fn(fname) running[fname] = true local ps = log.profile_start("find file %s", fname) - local line = core.get_nodes_starting_line() + + -- first line is the root node + local line = core.get_nodes_starting_line() - 1 local absolute_paths_searched = {} - local found = Iterator.builder(core.get_explorer().nodes) + local found = Iterator.builder({ core.get_explorer() }) :matcher(function(node) return node.absolute_path == fname_real or node.link_to == fname_real end) @@ -47,9 +49,7 @@ function M.fn(fname) if abs_match or link_match then node.open = true - if #node.nodes == 0 then - core.get_explorer():expand(node) - end + core.get_explorer():expand(node) end end) :recursor(function(node)