Skip to content

Commit be2ccd4

Browse files
authored
fix(#1723): find_file for externally created new file results in folder unable to be opened
* fix(#1723): find_file for externally created new file results in folder unable to be opened * fix(#1723): find_file for externally created new file results in folder unable to be opened
1 parent a0f3e99 commit be2ccd4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lua/nvim-tree/actions/finders/find-file.lua

+8-7
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@ function M.fn(fname)
1616
if running[fname] or not core.get_explorer() then
1717
return
1818
end
19-
running[fname] = true
2019

21-
local ps = log.profile_start("find file %s", fname)
2220
-- always match against the real path
2321
local fname_real = uv.fs_realpath(fname)
2422
if not fname_real then
2523
return
2624
end
2725

28-
local line = core.get_nodes_starting_line()
26+
running[fname] = true
27+
28+
local ps = log.profile_start("find file %s", fname)
29+
30+
-- first line is the root node
31+
local line = core.get_nodes_starting_line() - 1
2932

3033
local absolute_paths_searched = {}
3134

32-
local found = Iterator.builder(core.get_explorer().nodes)
35+
local found = Iterator.builder({ core.get_explorer() })
3336
:matcher(function(node)
3437
return node.absolute_path == fname_real or node.link_to == fname_real
3538
end)
@@ -46,9 +49,7 @@ function M.fn(fname)
4649

4750
if abs_match or link_match then
4851
node.open = true
49-
if #node.nodes == 0 then
50-
core.get_explorer():expand(node)
51-
end
52+
core.get_explorer():expand(node)
5253
end
5354
end)
5455
:recursor(function(node)

0 commit comments

Comments
 (0)