File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed
Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ function M.fn(path)
3232 local profile = log .profile_start (" find file %s" , path_real )
3333
3434 -- refresh the contents of all parents, expanding groups as needed
35- if utils . get_node_from_path (path_real ) == nil then
35+ if explorer : get_node_from_path (path_real ) == nil then
3636 explorer :refresh_parent_nodes_for_path (vim .fn .fnamemodify (path_real , " :h" ))
3737 end
3838
Original file line number Diff line number Diff line change @@ -572,6 +572,33 @@ function Explorer:find_node_line(node)
572572 return - 1
573573end
574574
575+ -- get the node in the tree state depending on the absolute path of the node
576+ -- (grouped or hidden too)
577+ --- @param path string
578+ --- @return Node | nil
579+ --- @return number | nil
580+ function Explorer :get_node_from_path (path )
581+
582+ if self .absolute_path == path then
583+ return self
584+ end
585+
586+ return Iterator .builder (self .nodes )
587+ :hidden ()
588+ :matcher (function (node )
589+ return node .absolute_path == path or node .link_to == path
590+ end )
591+ :recursor (function (node )
592+ if node .group_next then
593+ return { node .group_next }
594+ end
595+ if node .nodes then
596+ return node .nodes
597+ end
598+ end )
599+ :iterate ()
600+ end
601+
575602--- Api.tree.get_nodes
576603--- @return nvim_tree.api.Node
577604function Explorer :get_nodes ()
Original file line number Diff line number Diff line change @@ -233,7 +233,13 @@ local function reload_tree_at(toplevel)
233233 end
234234
235235 log .line (" watcher" , " git event executing '%s'" , toplevel )
236- local root_node = utils .get_node_from_path (toplevel )
236+
237+ local explorer = require (" nvim-tree.core" ).get_explorer ()
238+ if not explorer then
239+ return nil
240+ end
241+
242+ local root_node = explorer :get_node_from_path (toplevel )
237243 if not root_node then
238244 return
239245 end
@@ -252,7 +258,7 @@ local function reload_tree_at(toplevel)
252258 end )
253259 :iterate ()
254260
255- root_node . explorer .renderer :draw ()
261+ explorer .renderer :draw ()
256262 end )
257263end
258264
You can’t perform that action at this time.
0 commit comments