diff --git a/lua/nvim-tree/actions/finders/find-file.lua b/lua/nvim-tree/actions/finders/find-file.lua index df55c1551f2..87a4d0b4318 100644 --- a/lua/nvim-tree/actions/finders/find-file.lua +++ b/lua/nvim-tree/actions/finders/find-file.lua @@ -16,20 +16,23 @@ 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 - local line = core.get_nodes_starting_line() + running[fname] = true + + local ps = log.profile_start("find file %s", fname) + + -- 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) @@ -46,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)