Skip to content

Commit 3633cbb

Browse files
committed
feat(files): make async_directory_scan a three way toggle, allowing "never" and "always", part of #236
1 parent 4689290 commit 3633cbb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lua/neo-tree/defaults.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ local config = {
212212
["."] = "set_root",
213213
}
214214
},
215-
async_directory_scan = true, -- only applies to refreshes, it's alwsays sync when called from the Neotree commands.
215+
async_directory_scan = "auto", -- "auto" means refreshes are async, but it's synchronous when called from the Neotree commands.
216+
-- "always" means directory scans are always async.
217+
-- "never" means directory scans are never async.
216218
bind_to_cwd = true, -- true creates a 2-way binding between vim's cwd and neo-tree's root
217219
-- The renderer section provides the renderers that will be used to render the tree.
218220
-- The first level is the node type.

lua/neo-tree/sources/filesystem/lib/fs_scan.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,12 @@ M.get_items_async = function(state, parent_id, path_to_reveal, callback)
135135
end
136136

137137
M.get_items = function(state, parent_id, path_to_reveal, callback, async)
138-
if type(async) == "nil" then
139-
async = state.async_directory_scan
138+
if state.async_directory_scan == "always" then
139+
async = true
140+
elseif state.async_directory_scan == "never" then
141+
async = false
142+
elseif type(async) == "nil" then
143+
async = (state.async_directory_scan == "auto") or state.async_directory_scan
140144
end
141145

142146
if not parent_id then

0 commit comments

Comments
 (0)