File tree Expand file tree Collapse file tree 2 files changed +31
-34
lines changed
Expand file tree Collapse file tree 2 files changed +31
-34
lines changed Original file line number Diff line number Diff line change @@ -327,35 +327,6 @@ function DirectoryNode:descend_until_empty()
327327 return not should_exclude
328328end
329329
330- --- @private
331- --- @param expansion_count integer
332- --- @param node Node
333- --- @param should_descend fun ( expansion_count : integer , node : Node ): boolean
334- --- @return boolean
335- function DirectoryNode :should_expand (expansion_count , node , should_descend )
336- local dir = node :as (DirectoryNode )
337- if not dir then
338- return false
339- end
340-
341- if not dir .open and should_descend (expansion_count , node ) then
342- if # node .nodes == 0 then
343- node .explorer :expand_dir_node (dir ) -- populate node.group_next
344- end
345-
346- if dir .group_next then
347- local expand_next = self :should_expand (expansion_count , dir .group_next , should_descend )
348- if expand_next then
349- dir .open = true
350- end
351- return expand_next
352- else
353- return true
354- end
355- end
356- return false
357- end
358-
359330--- @param expand_opts ApiTreeExpandOpts ?
360331function DirectoryNode :expand (expand_opts )
361332 local expansion_count = 0
@@ -375,12 +346,9 @@ function DirectoryNode:expand(expand_opts)
375346 Iterator .builder (self .nodes )
376347 :hidden ()
377348 :applier (function (node )
378- if DirectoryNode :should_expand (expansion_count , node , should_descend ) then
349+ if node :should_expand (expansion_count , should_descend ) then
379350 expansion_count = expansion_count + 1
380- node = node :as (DirectoryNode )
381- if node then
382- node :expand_dir_node ()
383- end
351+ node :expand_dir_node ()
384352 end
385353 end )
386354 :recursor (function (node )
Original file line number Diff line number Diff line change @@ -144,6 +144,35 @@ function Node:clone(api_nodes)
144144 return clone
145145end
146146
147+ --- @param expansion_count integer
148+ --- @param should_descend fun ( expansion_count : integer , node : Node ): boolean
149+ --- @return boolean
150+ function Node :should_expand (expansion_count , should_descend )
151+ local DirectoryNode = require (" nvim-tree.node.directory" )
152+
153+ local dir = self :as (DirectoryNode )
154+ if not dir then
155+ return false
156+ end
157+
158+ if not dir .open and should_descend (expansion_count , self ) then
159+ if # self .nodes == 0 then
160+ self .explorer :expand_dir_node (dir ) -- populate node.group_next
161+ end
162+
163+ if dir .group_next then
164+ local expand_next = dir .group_next :should_expand (expansion_count , should_descend )
165+ if expand_next then
166+ dir .open = true
167+ end
168+ return expand_next
169+ else
170+ return true
171+ end
172+ end
173+ return false
174+ end
175+
147176--- @param expand_opts ApiTreeExpandOpts ?
148177function Node :expand (expand_opts )
149178 if self .parent then
You can’t perform that action at this time.
0 commit comments