@@ -8,6 +8,7 @@ local file_items = require("neo-tree.sources.common.file-items")
8
8
local log = require (" neo-tree.log" )
9
9
local fs_watch = require (" neo-tree.sources.filesystem.lib.fs_watch" )
10
10
local git = require (" neo-tree.git" )
11
+ local events = require (" neo-tree.events" )
11
12
12
13
local Path = require (" plenary.path" )
13
14
local os_sep = Path .path .sep
@@ -23,13 +24,22 @@ local on_directory_loaded = function(context, dir_path)
23
24
if state .use_libuv_file_watcher then
24
25
local root = context .folders [dir_path ]
25
26
if root then
26
- if root .is_link then
27
- log .trace (" Adding fs watcher for " , root .link_to )
28
- fs_watch .watch_folder (root .link_to )
29
- else
30
- log .trace (" Adding fs watcher for " , root .path )
31
- fs_watch .watch_folder (root .path )
32
- end
27
+ local target_path = root .is_link and root .link_to or root .path
28
+ local fs_watch_callback = vim .schedule_wrap (function (err , fname )
29
+ if err then
30
+ log .error (" file_event_callback: " , err )
31
+ return
32
+ end
33
+ if context .is_a_never_show_file (fname ) then
34
+ -- don't fire events for nodes that are designated as "never show"
35
+ return
36
+ else
37
+ events .fire_event (events .FS_EVENT , { afile = target_path })
38
+ end
39
+ end )
40
+
41
+ log .trace (" Adding fs watcher for " , target_path )
42
+ fs_watch .watch_folder (target_path , fs_watch_callback )
33
43
end
34
44
end
35
45
end
@@ -290,6 +300,22 @@ M.get_items = function(state, parent_id, path_to_reveal, callback, async, recurs
290
300
context .paths_to_load = utils .unique (context .paths_to_load )
291
301
end
292
302
end
303
+
304
+ local filtered_items = state .filtered_items or {}
305
+ context .is_a_never_show_file = function (fname )
306
+ if fname then
307
+ local _ , name = utils .split_path (fname )
308
+ if name then
309
+ if filtered_items .never_show and filtered_items .never_show [name ] then
310
+ return true
311
+ end
312
+ if utils .is_filtered_by_pattern (filtered_items .never_show_by_pattern , fname , name ) then
313
+ return true
314
+ end
315
+ end
316
+ end
317
+ return false
318
+ end
293
319
if async then
294
320
async_scan (context , path )
295
321
else
0 commit comments