fix(picker.git_diff): use absolute path when adding buffer to avoid duplicates (#1819)

## Description

Uses absolute path for setting the cursor
<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

## Related Issue(s)

Fixes #1818 
<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

## Screenshots

<!-- Add screenshots of the changes if applicable. -->

---------

Co-authored-by: Aaron Weisberg <aaron.weisberg@quizlet.com>
This commit is contained in:
Aaron Weisberg 2025-10-20 07:03:03 -07:00 committed by GitHub
parent 259cb01d7d
commit a012f394c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -216,9 +216,13 @@ function M.diff(opts, ctx)
local file, line ---@type string?, number?
local header, hunk = {}, {} ---@type string[], string[]
local header_len = 4
local cwd = svim.fs.normalize(opts and opts.cwd or uv.cwd() or ".") or nil
cwd = Snacks.git.get_root(cwd) or cwd
local finder = require("snacks.picker.source.proc").proc({
opts,
{ cmd = "git", args = args },
{ cmd = "git", args = args, cwd = cwd },
}, ctx)
return function(cb)
local function add()
@ -228,6 +232,7 @@ function M.diff(opts, ctx)
text = file .. ":" .. line,
diff = diff,
file = file,
cwd = cwd,
pos = { line, 0 },
preview = { text = diff, ft = "diff", loc = false },
})