@@ -3,40 +3,45 @@ local DirectoryNode = require("nvim-tree.node.directory")
33
44local M = {}
55
6- --- @param should_close boolean | nil
7- --- @return fun ( node : Node ): boolean | nil
8- function M .fn (should_close )
9- should_close = should_close or false
10-
11- --- @param node Node
12- return function (node )
13- local dir = node :as (DirectoryNode )
14- if dir then
15- dir = dir :last_group_node ()
16- if should_close and dir .open then
17- dir .open = false
18- dir .explorer .renderer :draw ()
19- return
20- end
6+ --- @param node Node
7+ --- @param should_close boolean
8+ local function move (node , should_close )
9+ local dir = node :as (DirectoryNode )
10+ if dir then
11+ dir = dir :last_group_node ()
12+ if should_close and dir .open then
13+ dir .open = false
14+ dir .explorer .renderer :draw ()
15+ return
2116 end
17+ end
2218
23- local parent = (node :get_parent_of_group () or node ).parent
19+ local parent = (node :get_parent_of_group () or node ).parent
2420
25- if not parent or not parent .parent then
26- view .set_cursor ({ 1 , 0 })
27- return
28- end
21+ if not parent or not parent .parent then
22+ view .set_cursor ({ 1 , 0 })
23+ return
24+ end
2925
30- local _ , line = parent .explorer :find_node (function (n )
31- return n .absolute_path == parent .absolute_path
32- end )
26+ local _ , line = parent .explorer :find_node (function (n )
27+ return n .absolute_path == parent .absolute_path
28+ end )
3329
34- view .set_cursor ({ line + 1 , 0 })
35- if should_close then
36- parent .open = false
37- parent .explorer .renderer :draw ()
38- end
30+ view .set_cursor ({ line + 1 , 0 })
31+ if should_close then
32+ parent .open = false
33+ parent .explorer .renderer :draw ()
3934 end
4035end
4136
37+ --- @param node Node
38+ function M .move (node )
39+ move (node , false )
40+ end
41+
42+ --- @param node Node
43+ function M .move_close (node )
44+ move (node , true )
45+ end
46+
4247return M
0 commit comments