Skip to content

Commit a012f39

Browse files
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 <[email protected]>
1 parent 259cb01 commit a012f39

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lua/snacks/picker/source/git.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,13 @@ function M.diff(opts, ctx)
216216
local file, line ---@type string?, number?
217217
local header, hunk = {}, {} ---@type string[], string[]
218218
local header_len = 4
219+
220+
local cwd = svim.fs.normalize(opts and opts.cwd or uv.cwd() or ".") or nil
221+
cwd = Snacks.git.get_root(cwd) or cwd
222+
219223
local finder = require("snacks.picker.source.proc").proc({
220224
opts,
221-
{ cmd = "git", args = args },
225+
{ cmd = "git", args = args, cwd = cwd },
222226
}, ctx)
223227
return function(cb)
224228
local function add()
@@ -228,6 +232,7 @@ function M.diff(opts, ctx)
228232
text = file .. ":" .. line,
229233
diff = diff,
230234
file = file,
235+
cwd = cwd,
231236
pos = { line, 0 },
232237
preview = { text = diff, ft = "diff", loc = false },
233238
})

0 commit comments

Comments
 (0)