feat(diff): Make both codediff/diffview work with the new Jedit

command to allow diffing agianst arbitrary revisions in buffer
This commit is contained in:
NicolasGB
2026-04-26 19:25:17 +02:00
parent 53a3196210
commit 167c206521
4 changed files with 197 additions and 10 deletions
+11 -3
View File
@@ -46,15 +46,23 @@ diff.register_backend("diffview", {
return
end
-- Extract the commit id from opts.rev
local revset = opts.rev or "@-"
local buf_name = vim.api.nvim_buf_get_name(0)
local change_id, jj_path = utils.parse_jj_uri(buf_name)
local revset = opts.rev or (change_id and (change_id .. "-")) or "@-"
local commit_id = utils.get_commit_id(revset)
if not commit_id then
return
end
vim.cmd(string.format("DiffviewOpen %s -- %%", commit_id))
local raw_path = opts.path or jj_path or "%"
local path, err = utils.normalize_repo_path(raw_path)
if not path then
utils.notify(err or "Could not resolve file path for Diffview", vim.log.levels.ERROR)
return
end
vim.cmd(string.format("DiffviewOpen %s -- %s", commit_id, vim.fn.fnameescape(path)))
vim.cmd("DiffviewToggleFiles")
end,
show_revision = function(opts)