Skip to content

Commit

Permalink
feat: Add more controll to expand-all function
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostbuster91 committed Sep 1, 2024
1 parent cd96cf9 commit 9f0a224
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lua/nvim-tree/actions/tree/modifiers/expand-all.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ end

---@param expansion_count integer
---@param node Node
---@return boolean
---@return boolean, function
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
local result = not should_halt and node.nodes and not node.open and not should_exclude
return result, expand_until_max_or_empty
end

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

return function(parent)
Expand All @@ -47,7 +48,9 @@ local function gen_iterator(should_expand)
Iterator.builder(parent.nodes)
:hidden()
:applier(function(node)
if should_expand(expansion_count, node) then
local should_expand, should_expand_next_fn = should_expand_fn(expansion_count, node)
should_expand_fn = should_expand_next_fn
if should_expand then
expansion_count = expansion_count + 1
expand(node)
end
Expand Down

0 comments on commit 9f0a224

Please sign in to comment.