Skip to content

Commit

Permalink
Add new parameter to expand function
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostbuster91 committed Sep 1, 2024
1 parent ea55ef1 commit cd96cf9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lua/nvim-tree/actions/tree/modifiers/expand-all.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ end
---@param expansion_count integer
---@param node Node
---@return boolean
local function should_expand(expansion_count, node)
local function expand_until_max_or_empty(expansion_count, node)
local should_halt = expansion_count >= M.MAX_FOLDER_DISCOVERY
local should_exclude = M.EXCLUDE[node.name]
return not should_halt and node.nodes and not node.open and not should_exclude
end

local function gen_iterator()
local function gen_iterator(should_expand)
local expansion_count = 0

return function(parent)
Expand Down Expand Up @@ -64,9 +64,10 @@ local function gen_iterator()
end

---@param base_node table
function M.fn(base_node)
function M.fn(base_node, expand_until)
expand_until = expand_until or expand_until_max_or_empty
local node = base_node.nodes and base_node or core.get_explorer()
if gen_iterator()(node) then
if gen_iterator(expand_until)(node) then
notify.warn("expansion iteration was halted after " .. M.MAX_FOLDER_DISCOVERY .. " discovered folders")
end
renderer.draw()
Expand Down

0 comments on commit cd96cf9

Please sign in to comment.