From cd96cf9c1d83d19610da050d30c1363d875b4c36 Mon Sep 17 00:00:00 2001 From: ghostbuster91 Date: Sat, 1 Jun 2024 13:44:38 +0200 Subject: [PATCH] Add new parameter to expand function --- lua/nvim-tree/actions/tree/modifiers/expand-all.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/nvim-tree/actions/tree/modifiers/expand-all.lua b/lua/nvim-tree/actions/tree/modifiers/expand-all.lua index 6af62e6ae49..b428806b7c6 100644 --- a/lua/nvim-tree/actions/tree/modifiers/expand-all.lua +++ b/lua/nvim-tree/actions/tree/modifiers/expand-all.lua @@ -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) @@ -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()