@@ -3,49 +3,49 @@ local log = require("neo-tree.log")
3
3
local M = {}
4
4
5
5
--- Recursively expand all loaded nodes under the given node
6
- --- returns table with all discovered nodes that need to be loaded
6
+ --- returns table with all discovered nodes that need to be loaded
7
7
--- @param node table a node to expand
8
8
--- @param state table current state of the source
9
9
--- @return table discovered nodes that need to be loaded
10
10
local function expand_loaded (node , state , prefetcher )
11
- local function rec (current_node , to_load )
12
- if prefetcher .should_prefetch (current_node ) then
13
- log .trace (" Node " .. current_node :get_id () .. " not loaded, saving for later" )
14
- table.insert (to_load , current_node )
15
- else
16
- if not current_node :is_expanded () then
17
- current_node :expand ()
18
- state .explicitly_opened_directories [current_node :get_id ()] = true
19
- end
20
- local children = state .tree :get_nodes (current_node :get_id ())
21
- log .debug (" Expanding childrens of " .. current_node :get_id ())
22
- for _ , child in ipairs (children ) do
23
- if child .type == " directory" then
24
- rec (child , to_load )
25
- else
26
- log .trace (" Child: " .. child .name .. " is not a directory, skipping" )
27
- end
11
+ local function rec (current_node , to_load )
12
+ if prefetcher .should_prefetch (current_node ) then
13
+ log .trace (" Node " .. current_node :get_id () .. " not loaded, saving for later" )
14
+ table.insert (to_load , current_node )
15
+ else
16
+ if not current_node :is_expanded () then
17
+ current_node :expand ()
18
+ state .explicitly_opened_directories [current_node :get_id ()] = true
19
+ end
20
+ local children = state .tree :get_nodes (current_node :get_id ())
21
+ log .debug (" Expanding childrens of " .. current_node :get_id ())
22
+ for _ , child in ipairs (children ) do
23
+ if child .type == " directory" then
24
+ rec (child , to_load )
25
+ else
26
+ log .trace (" Child: " .. child .name .. " is not a directory, skipping" )
28
27
end
29
28
end
30
29
end
30
+ end
31
31
32
- local to_load = {}
33
- rec (node , to_load )
34
- return to_load
32
+ local to_load = {}
33
+ rec (node , to_load )
34
+ return to_load
35
35
end
36
36
37
37
--- Recursively expands all nodes under the given node collecting all unloaded nodes
38
- --- Then run prefetcher on all unloaded nodes. Finally, expand loded nodes.
38
+ --- Then run prefetcher on all unloaded nodes. Finally, expand loded nodes.
39
39
--- async method
40
40
--- @param node table a node to expand
41
41
--- @param state table current state of the source
42
42
local function expand_and_load (node , state , prefetcher )
43
- local to_load = expand_loaded (node , state , prefetcher )
44
- for _ , _node in ipairs (to_load ) do
45
- prefetcher .prefetch (state , _node )
46
- -- no need to handle results as prefetch is recursive
47
- expand_loaded (_node , state , prefetcher )
48
- end
43
+ local to_load = expand_loaded (node , state , prefetcher )
44
+ for _ , _node in ipairs (to_load ) do
45
+ prefetcher .prefetch (state , _node )
46
+ -- no need to handle results as prefetch is recursive
47
+ expand_loaded (_node , state , prefetcher )
48
+ end
49
49
end
50
50
51
51
--- Expands given node recursively loading all descendant nodes if needed
@@ -71,12 +71,12 @@ M.expand_directory_recursively = function(state, node, prefetcher)
71
71
end
72
72
73
73
M .default_prefetcher = {
74
- prefetch = function (state , node )
74
+ prefetch = function (state , node )
75
75
log .debug (" Default expander prefetch does nothing" )
76
76
end ,
77
- should_prefetch = function (node )
77
+ should_prefetch = function (node )
78
78
return false
79
- end
79
+ end ,
80
80
}
81
81
82
82
return M
0 commit comments