File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,18 @@ local function buf_match()
2323 end
2424end
2525
26- --- @param node Node
27- --- @param keep_buffers boolean
28- function M .fn (node , keep_buffers )
26+ --- @param node Node | boolean | nil legacy -> opts.keep_buffers
27+ --- @param opts ApiTreeCollapseAllOpts | nil
28+ function M .fn (node , opts )
29+ -- legacy arguments
30+ if type (node ) == " boolean" then
31+ opts = {
32+ keep_buffers = node ,
33+ }
34+ node = nil
35+ end
36+ opts = opts or {}
37+
2938 local explorer = core .get_explorer ()
3039 if not explorer then
3140 return
@@ -51,7 +60,7 @@ function M.fn(node, keep_buffers)
5160 :applier (function (n )
5261 local dir = n :as (DirectoryNode )
5362 if dir then
54- dir .open = keep_buffers and matches (dir .absolute_path )
63+ dir .open = opts . keep_buffers and matches (dir .absolute_path )
5564 end
5665 end )
5766 :recursor (function (n )
Original file line number Diff line number Diff line change @@ -182,6 +182,10 @@ Api.tree.get_nodes = wrap_explorer("get_nodes")
182182
183183Api .tree .find_file = wrap (actions .tree .find_file .fn )
184184Api .tree .search_node = wrap (actions .finders .search_node .fn )
185+
186+ --- @class ApiTreeCollapseAllOpts
187+ --- @field keep_buffers boolean | nil default false
188+
185189Api .tree .collapse_all = wrap (actions .tree .modifiers .collapse_all .fn )
186190Api .tree .expand_all = wrap_node (actions .tree .modifiers .expand_all .fn )
187191Api .tree .toggle_enable_filters = wrap_explorer_member (" filters" , " toggle" )
You can’t perform that action at this time.
0 commit comments