mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
fix(picker.git): account for deleted files in git diff. Closes #1001
This commit is contained in:
parent
790d257c48
commit
e9e2e6976e
1 changed files with 6 additions and 1 deletions
|
@ -171,6 +171,7 @@ function M.diff(opts, ctx)
|
|||
local args = { "--no-pager", "diff", "--no-color", "--no-ext-diff" }
|
||||
local file, line ---@type string?, number?
|
||||
local header, hunk = {}, {} ---@type string[], string[]
|
||||
local header_len = 4
|
||||
local finder = require("snacks.picker.source.proc").proc({
|
||||
opts,
|
||||
{ cmd = "git", args = args },
|
||||
|
@ -194,7 +195,11 @@ function M.diff(opts, ctx)
|
|||
add()
|
||||
file = text:match("^diff .* a/(.*) b/.*$")
|
||||
header = { text }
|
||||
elseif file and #header < 4 then
|
||||
header_len = 4
|
||||
elseif file and #header < header_len then
|
||||
if text:find("^deleted file") then
|
||||
header_len = 5
|
||||
end
|
||||
header[#header + 1] = text
|
||||
elseif text:find("@", 1, true) == 1 then
|
||||
add()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue