@@ -17,11 +17,9 @@ local function to_lookup_table(list)
17
17
return table
18
18
end
19
19
20
- --- @param node Node
20
+ --- @param node DirectoryNode
21
21
local function expand (node )
22
- if node :is (DirectoryNode ) then
23
- node = node :last_group_node ()
24
- end
22
+ node = node :last_group_node ()
25
23
node .open = true
26
24
if # node .nodes == 0 then
27
25
core .get_explorer ():expand (node )
40
38
local function gen_iterator ()
41
39
local expansion_count = 0
42
40
41
+ --- @param parent DirectoryNode
43
42
return function (parent )
44
43
if parent .parent and parent .nodes and not parent .open then
45
44
expansion_count = expansion_count + 1
@@ -48,12 +47,14 @@ local function gen_iterator()
48
47
49
48
Iterator .builder (parent .nodes )
50
49
:hidden ()
50
+ --- @param node DirectoryNode
51
51
:applier (function (node )
52
52
if should_expand (expansion_count , node ) then
53
53
expansion_count = expansion_count + 1
54
54
expand (node )
55
55
end
56
56
end )
57
+ --- @param node DirectoryNode
57
58
:recursor (function (node )
58
59
return expansion_count < M .MAX_FOLDER_DISCOVERY and (node .group_next and { node .group_next } or (node .open and node .nodes ))
59
60
end )
@@ -65,11 +66,16 @@ local function gen_iterator()
65
66
end
66
67
end
67
68
69
+ --- Expand the directory node or the root
68
70
--- @param node Node
69
71
function M .fn (node )
70
72
local explorer = core .get_explorer ()
71
- node = node .nodes and node or explorer
72
- if gen_iterator ()(node ) then
73
+ local parent = node :as (DirectoryNode ) or explorer
74
+ if not parent then
75
+ return
76
+ end
77
+
78
+ if gen_iterator ()(parent ) then
73
79
notify .warn (" expansion iteration was halted after " .. M .MAX_FOLDER_DISCOVERY .. " discovered folders" )
74
80
end
75
81
if explorer then
0 commit comments