File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,10 @@ function M.fn(fname)
30
30
31
31
local profile = log .profile_start (" find file %s" , fname_real )
32
32
33
- -- we cannot wait for watchers
34
- reload .refresh_nodes_for_path (vim .fn .fnamemodify (fname_real , " :h" ))
33
+ -- we cannot wait for watchers to populate a new node
34
+ if utils .get_node_from_path (fname_real ) == nil then
35
+ reload .refresh_nodes_for_path (vim .fn .fnamemodify (fname_real , " :h" ))
36
+ end
35
37
36
38
local line = core .get_nodes_starting_line ()
37
39
Original file line number Diff line number Diff line change @@ -166,6 +166,9 @@ function M.refresh_nodes_for_path(path)
166
166
167
167
local profile = log .profile_start (" refresh_nodes_for_path %s" , path )
168
168
169
+ -- avoids cycles
170
+ local absolute_paths_refreshed = {}
171
+
169
172
NodeIterator .builder ({ explorer })
170
173
:hidden ()
171
174
:recursor (function (node )
@@ -177,10 +180,13 @@ function M.refresh_nodes_for_path(path)
177
180
end
178
181
end )
179
182
:applier (function (node )
180
- local abs_contains = node .absolute_path and path :match ( " ^ " .. node .absolute_path )
181
- local link_contains = node .link_to and path :match ( " ^ " .. node .link_to )
183
+ local abs_contains = node .absolute_path and path :find ( node .absolute_path , 1 , true ) == 1
184
+ local link_contains = node .link_to and path :find ( node .link_to , 1 , true ) == 1
182
185
if abs_contains or link_contains then
183
- M .refresh_node (node )
186
+ if not absolute_paths_refreshed [node .absolute_path ] then
187
+ absolute_paths_refreshed [node .absolute_path ] = true
188
+ M .refresh_node (node )
189
+ end
184
190
end
185
191
end )
186
192
:iterate ()
You can’t perform that action at this time.
0 commit comments