Skip to content

Commit 9f0a224

Browse files
committed
feat: Add more controll to expand-all function
1 parent cd96cf9 commit 9f0a224

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lua/nvim-tree/actions/tree/modifiers/expand-all.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ end
2828

2929
---@param expansion_count integer
3030
---@param node Node
31-
---@return boolean
31+
---@return boolean, function
3232
local function expand_until_max_or_empty(expansion_count, node)
3333
local should_halt = expansion_count >= M.MAX_FOLDER_DISCOVERY
3434
local should_exclude = M.EXCLUDE[node.name]
35-
return not should_halt and node.nodes and not node.open and not should_exclude
35+
local result = not should_halt and node.nodes and not node.open and not should_exclude
36+
return result, expand_until_max_or_empty
3637
end
3738

38-
local function gen_iterator(should_expand)
39+
local function gen_iterator(should_expand_fn)
3940
local expansion_count = 0
4041

4142
return function(parent)
@@ -47,7 +48,9 @@ local function gen_iterator(should_expand)
4748
Iterator.builder(parent.nodes)
4849
:hidden()
4950
:applier(function(node)
50-
if should_expand(expansion_count, node) then
51+
local should_expand, should_expand_next_fn = should_expand_fn(expansion_count, node)
52+
should_expand_fn = should_expand_next_fn
53+
if should_expand then
5154
expansion_count = expansion_count + 1
5255
expand(node)
5356
end

0 commit comments

Comments
 (0)