@@ -46,39 +46,57 @@ local function is_folder_ignored(path)
46
46
return false
47
47
end
48
48
49
- function M .refresh_path (path )
50
- log .line (" watcher" , " node event executing '%s'" , path )
51
- local n = utils .get_node_from_path (path )
52
- if not n then
49
+ function M .refresh_node (node )
50
+ if type (node ) ~= " table" then
53
51
return
54
52
end
55
53
56
- local node = utils .get_parent_of_group (n )
54
+ if node .link_to then
55
+ log .line (" watcher" , " node event executing refresh '%s' -> '%s'" , node .link_to , node .absolute_path )
56
+ else
57
+ log .line (" watcher" , " node event executing refresh '%s'" , node .absolute_path )
58
+ end
59
+
60
+ local path = node .absolute_path
61
+
62
+ local parent_node = utils .get_parent_of_group (node )
63
+
57
64
local project_root , project = reload_and_get_git_project (path )
58
- require (" nvim-tree.explorer.reload" ).reload (node , project )
59
- update_parent_statuses (node , project , project_root )
65
+
66
+ require (" nvim-tree.explorer.reload" ).reload (parent_node , project )
67
+
68
+ update_parent_statuses (parent_node , project , project_root )
60
69
61
70
require (" nvim-tree.renderer" ).draw ()
62
71
end
63
72
64
- function M .create_watcher (absolute_path )
65
- if not M .enabled then
73
+ function M .create_watcher (node )
74
+ if not M .enabled or type ( node ) ~= " table " then
66
75
return nil
67
76
end
68
- if is_git (absolute_path ) or is_folder_ignored (absolute_path ) then
77
+
78
+ local path
79
+ if node .type == " link" then
80
+ path = node .link_to
81
+ else
82
+ path = node .absolute_path
83
+ end
84
+
85
+ if is_git (path ) or is_folder_ignored (path ) then
69
86
return nil
70
87
end
71
88
72
89
local function callback (watcher )
73
- log .line (" watcher" , " node event scheduled %s" , watcher .context )
90
+ log .line (" watcher" , " node event scheduled refresh %s" , watcher .context )
74
91
utils .debounce (watcher .context , M .debounce_delay , function ()
75
- M .refresh_path ( watcher . _path )
92
+ M .refresh_node ( node )
76
93
end )
77
94
end
78
95
79
96
M .uid = M .uid + 1
80
- return Watcher :new (absolute_path , nil , callback , {
81
- context = " explorer:watch:" .. absolute_path .. " :" .. M .uid ,
97
+ return Watcher :new (path , nil , callback , {
98
+ context = " explorer:watch:" .. path .. " :" .. M .uid ,
99
+ node = node ,
82
100
})
83
101
end
84
102
0 commit comments