mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 03:08:13 +00:00
perf(explorer): no need to get git status with -uall
. Closes #983
This commit is contained in:
parent
17360e4009
commit
bc087d36d6
3 changed files with 16 additions and 5 deletions
|
@ -30,7 +30,7 @@ function M.is_dirty(cwd)
|
|||
end
|
||||
|
||||
---@param cwd string
|
||||
---@param opts? {on_update?: fun(), ttl?: number, force?: boolean}
|
||||
---@param opts? {on_update?: fun(), ttl?: number, force?: boolean, ignored?: boolean}
|
||||
function M.update(cwd, opts)
|
||||
opts = opts or {}
|
||||
local ttl = opts.ttl or CACHE_TTL
|
||||
|
@ -62,7 +62,7 @@ function M.update(cwd, opts)
|
|||
args = {
|
||||
"--no-pager",
|
||||
"status",
|
||||
"-uall",
|
||||
"-unormal",
|
||||
"--porcelain=v1",
|
||||
"--ignored=matching",
|
||||
"-z",
|
||||
|
@ -135,6 +135,10 @@ function M._update(cwd, results)
|
|||
if not deleted then
|
||||
add_git_status(path, s.status)
|
||||
end
|
||||
if is_dir then
|
||||
local n = Tree:find(path)
|
||||
n.dir_status = s.status
|
||||
end
|
||||
if s.status:sub(1, 1) ~= "!" then -- don't propagate ignored status
|
||||
add_git_status(cwd, s.status)
|
||||
for dir in Snacks.picker.util.parents(path, cwd) do
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
---@field path string
|
||||
---@field name string
|
||||
---@field hidden? boolean
|
||||
---@field status? string
|
||||
---@field status? string merged git status
|
||||
---@field dir_status? string git status of the directory
|
||||
---@field ignored? boolean
|
||||
---@field type "file"|"directory"|"link"|"fifo"|"socket"|"char"|"block"|"unknown"
|
||||
---@field dir? boolean
|
||||
|
|
|
@ -234,15 +234,21 @@ function M.explorer(opts, ctx)
|
|||
local top = Tree:find(ctx.filter.cwd)
|
||||
local last = {} ---@type table<snacks.picker.explorer.Node, snacks.picker.explorer.Item>
|
||||
Tree:get(ctx.filter.cwd, function(node)
|
||||
local parent = node.parent and items[node.parent.path] or nil
|
||||
local status = node.status
|
||||
if not status and parent and parent.dir_status then
|
||||
status = parent.dir_status
|
||||
end
|
||||
local item = {
|
||||
file = node.path,
|
||||
dir = node.dir,
|
||||
open = node.open,
|
||||
dir_status = node.dir_status or parent and parent.dir_status,
|
||||
text = node.path,
|
||||
parent = node.parent and items[node.parent.path] or nil,
|
||||
parent = parent,
|
||||
hidden = node.hidden,
|
||||
ignored = node.ignored,
|
||||
status = (not node.dir or not node.open or opts.git_status_open) and node.status or nil,
|
||||
status = (not node.dir or not node.open or opts.git_status_open) and status or nil,
|
||||
last = true,
|
||||
type = node.type,
|
||||
severity = (not node.dir or not node.open or opts.diagnostics_open) and node.severity or nil,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue