Skip to content

Commit

Permalink
perf(explorer): early exit for tree calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Feb 6, 2025
1 parent c72e62e commit 1a30610
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lua/snacks/picker/source/explorer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1a30610

Please sign in to comment.