Skip to content

Commit b67209a

Browse files
committed
luals types for expand_until, rename variable for consistency
1 parent b506e05 commit b67209a

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

doc/nvim-tree-lua.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,8 @@ tree.expand_all({opts}) *nvim-tree-api.tree.expand_all()*
18161816
{opts} (table) optional parameters
18171817

18181818
Options: ~
1819-
• {expand_until} (function) A function returning boolean that
1819+
• {expand_until} (fun(expansion_count: integer, node: Node): boolean)
1820+
A function returning boolean that
18201821
specifies terminating condition for node/tree expansion. If not
18211822
provided the function that expands recursively entire node/tree will be
18221823
used.

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ local function expand_until_max_or_empty(expansion_count, node)
4242
return not should_halt and node.nodes and not node.open and not should_exclude
4343
end
4444

45-
local function gen_iterator(should_expand)
45+
---@param expand_until fun(expansion_count: integer, node: Node): boolean
46+
local function gen_iterator(expand_until)
4647
local expansion_count = 0
4748
local function expand(node)
4849
populate_node(node)
@@ -59,13 +60,13 @@ local function gen_iterator(should_expand)
5960
Iterator.builder(parent.nodes)
6061
:hidden()
6162
:applier(function(node)
62-
if should_expand(expansion_count, node, populate_node) then
63+
if expand_until(expansion_count, node, populate_node) then
6364
expansion_count = expansion_count + 1
6465
expand(node)
6566
end
6667
end)
6768
:recursor(function(node)
68-
local should_recurse = should_expand(expansion_count - 1, node, populate_node)
69+
local should_recurse = expand_until(expansion_count - 1, node, populate_node)
6970
return expansion_count < M.MAX_FOLDER_DISCOVERY and should_recurse and node.nodes
7071
end)
7172
:iterate()

lua/nvim-tree/api.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Api.tree.search_node = wrap(actions.finders.search_node.fn)
146146
Api.tree.collapse_all = wrap(actions.tree.modifiers.collapse_all.fn)
147147

148148
---@class ApiTreeExpandAllOpts
149-
---@field expand_until function|nil
149+
---@field expand_until (fun(expansion_count: integer, node: Node): boolean)|nil
150150

151151
Api.tree.expand_all = wrap_node(actions.tree.modifiers.expand_all.fn)
152152

0 commit comments

Comments
 (0)