feat(diff): Add the diff_history command (#97)

This new command is natively implemented by both the `codediff` and `diffview` backends allowing to easily navigate the changes between two revsets while diffing the. 

It also gives a new `:J diff_hisotyr` command that optionally takes a range of revsets formatted `<rev1>..<rev2>` otherwise it prompts the user for the range.
This commit is contained in:
Nicolas GB
2026-03-12 18:03:23 +01:00
committed by GitHub
parent ec44937e1b
commit 1c3d38a626
8 changed files with 184 additions and 3 deletions
+23
View File
@@ -28,6 +28,21 @@ local function diff_two_changes(left, right)
vim.cmd(string.format("CodeDiff %s %s", commit_id_right, commit_id_left))
end
local function diff_two_changes_with_history(left, right)
local commit_id_left = utils.get_commit_id(left)
if commit_id_left == nil then
return
end
local commit_id_right = utils.get_commit_id(right)
if commit_id_right == nil then
return
end
-- test
vim.cmd(string.format("CodeDiff history %s..%s", commit_id_right, commit_id_left))
end
-----------------------------------------------------------------------
-- Codediff Backend
-----------------------------------------------------------------------
@@ -67,4 +82,12 @@ diff.register_backend("codediff", {
diff_two_changes(opts.left, opts.right)
end,
diff_history_revisions = function(opts)
if not utils.has_dependency("codediff") then
return
end
diff_two_changes_with_history(opts.left, opts.right)
end,
})