mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-06 19:26:12 +00:00
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:
@@ -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,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user