38
38
--- @param expansion_count integer
39
39
--- @param node Node
40
40
--- @param populate_node function
41
- --- @return boolean , function
41
+ --- @return boolean
42
42
-- luacheck: push ignore populate_node
43
43
local function expand_until_max_or_empty (expansion_count , node , populate_node )
44
44
local should_halt = expansion_count >= M .MAX_FOLDER_DISCOVERY
45
45
local should_exclude = M .EXCLUDE [node .name ]
46
46
local result = not should_halt and node .nodes and not node .open and not should_exclude
47
- return result , expand_until_max_or_empty
47
+ return result
48
48
end
49
49
-- luacheck: pop
50
50
@@ -58,8 +58,7 @@ local function gen_iterator(should_expand_fn)
58
58
Iterator .builder ({ parent })
59
59
:hidden ()
60
60
:applier (function (node )
61
- local should_expand , should_expand_next_fn = should_expand_fn (expansion_count , node , populate_node )
62
- should_expand_fn = should_expand_next_fn
61
+ local should_expand = should_expand_fn (expansion_count , node , populate_node )
63
62
if should_expand then
64
63
expansion_count = expansion_count + 1
65
64
populate_node (node )
@@ -68,7 +67,8 @@ local function gen_iterator(should_expand_fn)
68
67
end
69
68
end )
70
69
:recursor (function (node )
71
- return expansion_count < M .MAX_FOLDER_DISCOVERY and (node .group_next and { node .group_next } or (node .open and node .nodes ))
70
+ local should_recurse = should_expand_fn (expansion_count - 1 , node , populate_node )
71
+ return expansion_count < M .MAX_FOLDER_DISCOVERY and (should_recurse and node .open and node .nodes )
72
72
end )
73
73
:iterate ()
74
74
0 commit comments