mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-06 03:38:16 +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
|
end
|
||||||
|
|
||||||
---@param cwd string
|
---@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)
|
function M.update(cwd, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local ttl = opts.ttl or CACHE_TTL
|
local ttl = opts.ttl or CACHE_TTL
|
||||||
|
@ -62,7 +62,7 @@ function M.update(cwd, opts)
|
||||||
args = {
|
args = {
|
||||||
"--no-pager",
|
"--no-pager",
|
||||||
"status",
|
"status",
|
||||||
"-uall",
|
"-unormal",
|
||||||
"--porcelain=v1",
|
"--porcelain=v1",
|
||||||
"--ignored=matching",
|
"--ignored=matching",
|
||||||
"-z",
|
"-z",
|
||||||
|
@ -135,6 +135,10 @@ function M._update(cwd, results)
|
||||||
if not deleted then
|
if not deleted then
|
||||||
add_git_status(path, s.status)
|
add_git_status(path, s.status)
|
||||||
end
|
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
|
if s.status:sub(1, 1) ~= "!" then -- don't propagate ignored status
|
||||||
add_git_status(cwd, s.status)
|
add_git_status(cwd, s.status)
|
||||||
for dir in Snacks.picker.util.parents(path, cwd) do
|
for dir in Snacks.picker.util.parents(path, cwd) do
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
---@field path string
|
---@field path string
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field hidden? boolean
|
---@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 ignored? boolean
|
||||||
---@field type "file"|"directory"|"link"|"fifo"|"socket"|"char"|"block"|"unknown"
|
---@field type "file"|"directory"|"link"|"fifo"|"socket"|"char"|"block"|"unknown"
|
||||||
---@field dir? boolean
|
---@field dir? boolean
|
||||||
|
|
|
@ -234,15 +234,21 @@ function M.explorer(opts, ctx)
|
||||||
local top = Tree:find(ctx.filter.cwd)
|
local top = Tree:find(ctx.filter.cwd)
|
||||||
local last = {} ---@type table<snacks.picker.explorer.Node, snacks.picker.explorer.Item>
|
local last = {} ---@type table<snacks.picker.explorer.Node, snacks.picker.explorer.Item>
|
||||||
Tree:get(ctx.filter.cwd, function(node)
|
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 = {
|
local item = {
|
||||||
file = node.path,
|
file = node.path,
|
||||||
dir = node.dir,
|
dir = node.dir,
|
||||||
open = node.open,
|
open = node.open,
|
||||||
|
dir_status = node.dir_status or parent and parent.dir_status,
|
||||||
text = node.path,
|
text = node.path,
|
||||||
parent = node.parent and items[node.parent.path] or nil,
|
parent = parent,
|
||||||
hidden = node.hidden,
|
hidden = node.hidden,
|
||||||
ignored = node.ignored,
|
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,
|
last = true,
|
||||||
type = node.type,
|
type = node.type,
|
||||||
severity = (not node.dir or not node.open or opts.diagnostics_open) and node.severity or nil,
|
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