1
1
-- This file should contain all commands meant to be used by mappings.
2
-
3
2
local vim = vim
4
3
local fs_actions = require (" neo-tree.sources.filesystem.lib.fs_actions" )
5
4
local utils = require (" neo-tree.utils" )
@@ -113,17 +112,17 @@ end
113
112
--- Expand all nodes
114
113
--- @param state table The state of the source
115
114
--- @param node table A node to expand
116
- --- @param prefetcher table an object with two methods ` prefetch(state, node)` and ` should_prefetch(node) => boolean`
115
+ --- @param prefetcher table ? an object with two methods ` prefetch(state, node)` and ` should_prefetch(node) => boolean`
117
116
M .expand_all_nodes = function (state , node , prefetcher )
118
- log .debug (" Expanding all nodes under " .. node :get_id ())
119
- if prefetcher == nil then
120
- prefetcher = node_expander .default_prefetcher
121
- end
117
+ local root_nodes = node and { node } or state .tree :get_nodes ()
122
118
123
119
renderer .position .set (state , nil )
124
120
125
121
local task = function ()
126
- node_expander .expand_directory_recursively (state , node , prefetcher )
122
+ for _ , root in pairs (root_nodes ) do
123
+ log .debug (" Expanding all nodes under " .. root :get_id ())
124
+ node_expander .expand_directory_recursively (state , root , prefetcher )
125
+ end
127
126
end
128
127
async .run (task , function ()
129
128
log .debug (" All nodes expanded - redrawing" )
@@ -150,11 +149,8 @@ M.close_node = function(state, callback)
150
149
target_node :collapse ()
151
150
renderer .redraw (state )
152
151
renderer .focus_node (state , target_node :get_id ())
153
- if
154
- state .explicitly_opened_directories
155
- and state .explicitly_opened_directories [target_node :get_id ()]
156
- then
157
- state .explicitly_opened_directories [target_node :get_id ()] = false
152
+ if state .explicitly_opened_nodes and state .explicitly_opened_nodes [target_node :get_id ()] then
153
+ state .explicitly_opened_nodes [target_node :get_id ()] = false
158
154
end
159
155
end
160
156
end
@@ -174,16 +170,13 @@ M.close_all_subnodes = function(state)
174
170
renderer .collapse_all_nodes (tree , target_node :get_id ())
175
171
renderer .redraw (state )
176
172
renderer .focus_node (state , target_node :get_id ())
177
- if
178
- state .explicitly_opened_directories
179
- and state .explicitly_opened_directories [target_node :get_id ()]
180
- then
181
- state .explicitly_opened_directories [target_node :get_id ()] = false
173
+ if state .explicitly_opened_nodes and state .explicitly_opened_nodes [target_node :get_id ()] then
174
+ state .explicitly_opened_nodes [target_node :get_id ()] = false
182
175
end
183
176
end
184
177
185
178
M .close_all_nodes = function (state )
186
- state .explicitly_opened_directories = {}
179
+ state .explicitly_opened_nodes = {}
187
180
renderer .collapse_all_nodes (state .tree )
188
181
renderer .redraw (state )
189
182
end
0 commit comments