File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change 4848--- @return boolean
4949local function should_expand (expansion_count , node , should_descend )
5050 local dir = node :as (DirectoryNode )
51- return dir and not dir .open and should_descend (expansion_count , node )
51+ if not dir then
52+ return false
53+ end
54+
55+ return not dir .open and should_descend (expansion_count , node )
5256end
5357
5458
5559--- @param should_descend fun ( expansion_count : integer , node : Node ): boolean
60+ --- @return fun ( node ): any
5661local function gen_iterator (should_descend )
5762 local expansion_count = 0
5863
Original file line number Diff line number Diff line change @@ -232,15 +232,15 @@ Api.tree.collapse_all = wrap(actions.tree.modifiers.collapse.all)
232232Api .tree .expand_all = wrap_node (actions .tree .modifiers .expand .all )
233233
234234Api .tree .toggle_descend_until = wrap_node (function (node , descend_until )
235- if node .open then
236- local dir = node :as (DirectoryNode )
237- dir :expand_or_collapse (" edit" )
238- else
239- if node .nodes then
240- actions .tree .modifiers .expand .all (node , { descend_until = descend_until })
235+ local dir = node :as (DirectoryNode )
236+ if dir then
237+ if node .open then
238+ dir :expand_or_collapse (nil )
241239 else
242- edit ( " edit " , node )
240+ actions . tree . modifiers . expand . all ( node , { descend_until = descend_until } )
243241 end
242+ else
243+ edit (" edit" , node )
244244 end
245245end )
246246
You can’t perform that action at this time.
0 commit comments