Skip to content

Commit 6011391

Browse files
authored
fix(fs_scan): ensure parents of all expanded nodes are also scanned (#1393)
1 parent 403a9c5 commit 6011391

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,22 @@ local handle_refresh_or_up = function (context, async)
481481
elseif state.tree then
482482
context.paths_to_load = renderer.get_expanded_nodes(state.tree, state.path)
483483
end
484+
-- Ensure parents of all expanded nodes are also scanned
485+
if #context.paths_to_load > 0 and state.tree then
486+
local seen = {}
487+
for _, p in ipairs(context.paths_to_load) do
488+
local current = p
489+
while current do
490+
if seen[current] then
491+
break
492+
end
493+
seen[current] = true
494+
local current_node = state.tree:get_node(current)
495+
current = current_node and current_node:get_parent_id()
496+
end
497+
end
498+
context.paths_to_load = vim.tbl_keys(seen)
499+
end
484500
-- Ensure that there are no nested files in the list of folders to load
485501
context.paths_to_load = vim.tbl_filter(function(p)
486502
local stats = vim.loop.fs_stat(p)

0 commit comments

Comments
 (0)