Skip to content

Commit cd96cf9

Browse files
committed
Add new parameter to expand function
1 parent ea55ef1 commit cd96cf9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ end
2929
---@param expansion_count integer
3030
---@param node Node
3131
---@return boolean
32-
local function should_expand(expansion_count, node)
32+
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]
3535
return not should_halt and node.nodes and not node.open and not should_exclude
3636
end
3737

38-
local function gen_iterator()
38+
local function gen_iterator(should_expand)
3939
local expansion_count = 0
4040

4141
return function(parent)
@@ -64,9 +64,10 @@ local function gen_iterator()
6464
end
6565

6666
---@param base_node table
67-
function M.fn(base_node)
67+
function M.fn(base_node, expand_until)
68+
expand_until = expand_until or expand_until_max_or_empty
6869
local node = base_node.nodes and base_node or core.get_explorer()
69-
if gen_iterator()(node) then
70+
if gen_iterator(expand_until)(node) then
7071
notify.warn("expansion iteration was halted after " .. M.MAX_FOLDER_DISCOVERY .. " discovered folders")
7172
end
7273
renderer.draw()

0 commit comments

Comments
 (0)