fix(picker.git): show diff for staged files. Fixes #747

This commit is contained in:
Folke Lemaitre 2025-01-28 09:08:15 +01:00
parent fdea74984a
commit e87f0ffcd1
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -296,9 +296,11 @@ function M.git_diff(ctx)
"-c",
"delta." .. vim.o.background .. "=true",
"diff",
"--",
ctx.item.file,
"HEAD",
}
if ctx.item.file then
vim.list_extend(cmd, { "--", ctx.item.file })
end
if not native then
table.insert(cmd, 2, "--no-pager")
end
@ -307,8 +309,8 @@ end
---@param ctx snacks.picker.preview.ctx
function M.git_status(ctx)
local s = vim.trim(ctx.item.status):sub(1, 1)
if s == "?" then
local ss = ctx.item.status
if ss:find("^[A?]") then
M.file(ctx)
else
M.git_diff(ctx)