@@ -3,6 +3,7 @@ local view = require "nvim-tree.view"
33local utils = require " nvim-tree.utils"
44local renderer = require " nvim-tree.renderer"
55local core = require " nvim-tree.core"
6+ local reloaders = require " nvim-tree.actions.reloaders.reloaders"
67local Iterator = require " nvim-tree.iterators.node-iterator"
78
89local M = {}
@@ -12,18 +13,27 @@ local running = {}
1213--- Find a path in the tree, expand it and focus it
1314--- @param fname string full path
1415function M .fn (fname )
15- if running [ fname ] or not core .get_explorer () then
16+ if not core .get_explorer () then
1617 return
1718 end
18- running [fname ] = true
1919
20- local ps = log .profile_start (" find file %s" , fname )
2120 -- always match against the real path
2221 local fname_real = vim .loop .fs_realpath (fname )
2322 if not fname_real then
2423 return
2524 end
2625
26+ if running [fname_real ] then
27+ return
28+ end
29+ running [fname_real ] = true
30+
31+ local ps = log .profile_start (" find file %s" , fname_real )
32+
33+ if not M .filesystem_watchers_enabled then
34+ reloaders .reload_explorer ()
35+ end
36+
2737 local line = core .get_nodes_starting_line ()
2838
2939 local absolute_paths_searched = {}
@@ -60,9 +70,13 @@ function M.fn(fname)
6070 view .set_cursor { line , 0 }
6171 end
6272
63- running [fname ] = false
73+ running [fname_real ] = false
74+
75+ log .profile_end (ps , " find file %s" , fname_real )
76+ end
6477
65- log .profile_end (ps , " find file %s" , fname )
78+ function M .setup (opts )
79+ M .filesystem_watchers_enabled = opts .filesystem_watchers .enabled
6680end
6781
6882return M
0 commit comments