Skip to content

Commit 38d9e07

Browse files
committed
Minimize amount of changes further
1 parent 57af3c4 commit 38d9e07

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,24 @@ end
4444

4545
local function gen_iterator(should_expand)
4646
local expansion_count = 0
47+
local function expand(node)
48+
populate_node(node)
49+
node = lib.get_last_group_node(node)
50+
node.open = true
51+
end
4752

4853
return function(parent)
49-
populate_node(parent)
50-
parent.open = true
54+
if parent.parent and parent.nodes and not parent.open then
55+
expansion_count = expansion_count + 1
56+
expand(parent)
57+
end
5158

52-
Iterator.builder({ parent })
59+
Iterator.builder(parent.nodes)
5360
:hidden()
5461
:applier(function(node)
5562
if should_expand(expansion_count, node, populate_node) then
5663
expansion_count = expansion_count + 1
57-
populate_node(node)
58-
node = lib.get_last_group_node(node)
59-
node.open = true
64+
expand(node)
6065
end
6166
end)
6267
:recursor(function(node)

0 commit comments

Comments
 (0)