Skip to content

Commit

Permalink
fix(fs_scan): ensure parents of all expanded nodes are also scanned (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pysan3 committed Mar 20, 2024
1 parent 403a9c5 commit 6011391
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lua/neo-tree/sources/filesystem/lib/fs_scan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,22 @@ local handle_refresh_or_up = function (context, async)
elseif state.tree then
context.paths_to_load = renderer.get_expanded_nodes(state.tree, state.path)
end
-- Ensure parents of all expanded nodes are also scanned
if #context.paths_to_load > 0 and state.tree then
local seen = {}
for _, p in ipairs(context.paths_to_load) do
local current = p
while current do
if seen[current] then
break
end
seen[current] = true
local current_node = state.tree:get_node(current)
current = current_node and current_node:get_parent_id()
end
end
context.paths_to_load = vim.tbl_keys(seen)
end
-- Ensure that there are no nested files in the list of folders to load
context.paths_to_load = vim.tbl_filter(function(p)
local stats = vim.loop.fs_stat(p)
Expand Down

0 comments on commit 6011391

Please sign in to comment.