From 6011391412b003ffbaf5615d6df8ade154726117 Mon Sep 17 00:00:00 2001 From: takuto Date: Wed, 20 Mar 2024 11:15:18 +0900 Subject: [PATCH] fix(fs_scan): ensure parents of all expanded nodes are also scanned (#1393) --- lua/neo-tree/sources/filesystem/lib/fs_scan.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lua/neo-tree/sources/filesystem/lib/fs_scan.lua b/lua/neo-tree/sources/filesystem/lib/fs_scan.lua index 741a549b..86dc4d35 100644 --- a/lua/neo-tree/sources/filesystem/lib/fs_scan.lua +++ b/lua/neo-tree/sources/filesystem/lib/fs_scan.lua @@ -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)