perf(explorer): early exit for tree calculation

This commit is contained in:
Folke Lemaitre 2025-02-06 14:29:45 +01:00
parent c72e62ef90
commit 1a30610ab7
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -295,7 +295,7 @@ function M.search(opts, ctx)
item.hidden = true
end
item.text = item.text:sub(1, #opts.cwd) == opts.cwd and item.text:sub(#opts.cwd + 2) or item.text
local node = Tree:find(item.file)
local node = Tree:node(item.file)
if node then
item.status = (not node.dir or opts.git_status_open) and node.status or nil
end
@ -334,7 +334,9 @@ function M.search(opts, ctx)
-- Add parents when needed
for dir in Snacks.picker.util.parents(item.file, opts.cwd) do
if not dirs[dir] then
if dirs[dir] then
break
else
dirs[dir] = {
text = dir,
file = dir,