From a012f394c9988ec30ec03474d5b971e1796ee3dd Mon Sep 17 00:00:00 2001 From: Aaron Weisberg Date: Mon, 20 Oct 2025 07:03:03 -0700 Subject: [PATCH] fix(picker.git_diff): use absolute path when adding buffer to avoid duplicates (#1819) ## Description Uses absolute path for setting the cursor ## Related Issue(s) Fixes #1818 ## Screenshots --------- Co-authored-by: Aaron Weisberg --- lua/snacks/picker/source/git.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/snacks/picker/source/git.lua b/lua/snacks/picker/source/git.lua index 746c410e..d9d6ffb0 100644 --- a/lua/snacks/picker/source/git.lua +++ b/lua/snacks/picker/source/git.lua @@ -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 }, })