@@ -3,6 +3,7 @@ local view = require "nvim-tree.view"
3
3
local utils = require " nvim-tree.utils"
4
4
local renderer = require " nvim-tree.renderer"
5
5
local core = require " nvim-tree.core"
6
+ local reloaders = require " nvim-tree.actions.reloaders.reloaders"
6
7
local Iterator = require " nvim-tree.iterators.node-iterator"
7
8
8
9
local M = {}
@@ -12,18 +13,27 @@ local running = {}
12
13
--- Find a path in the tree, expand it and focus it
13
14
--- @param fname string full path
14
15
function M .fn (fname )
15
- if running [ fname ] or not core .get_explorer () then
16
+ if not core .get_explorer () then
16
17
return
17
18
end
18
- running [fname ] = true
19
19
20
- local ps = log .profile_start (" find file %s" , fname )
21
20
-- always match against the real path
22
21
local fname_real = vim .loop .fs_realpath (fname )
23
22
if not fname_real then
24
23
return
25
24
end
26
25
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
+
27
37
local line = core .get_nodes_starting_line ()
28
38
29
39
local absolute_paths_searched = {}
@@ -60,9 +70,13 @@ function M.fn(fname)
60
70
view .set_cursor { line , 0 }
61
71
end
62
72
63
- running [fname ] = false
73
+ running [fname_real ] = false
74
+
75
+ log .profile_end (ps , " find file %s" , fname_real )
76
+ end
64
77
65
- log .profile_end (ps , " find file %s" , fname )
78
+ function M .setup (opts )
79
+ M .filesystem_watchers_enabled = opts .filesystem_watchers .enabled
66
80
end
67
81
68
82
return M
0 commit comments