mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-15 23:53:18 +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:
@@ -428,6 +428,26 @@ function M.handle_log_diff()
|
||||
end
|
||||
end
|
||||
|
||||
--- Handle log history
|
||||
function M.handle_log_history()
|
||||
local revsets = extract_revsets_from_terminal_buffer()
|
||||
if not revsets then
|
||||
utils.notify("No valid revision found in the log line", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
-- Delete the pipes from the revsets string since jj new expects space separated revsets
|
||||
revsets = revsets:gsub("| ", "")
|
||||
|
||||
local is_multiple = revsets:find(" ") ~= nil
|
||||
|
||||
if is_multiple then
|
||||
-- Get the first and the last revset to diff
|
||||
local list = vim.split(revsets, "%s+", { trimempty = true })
|
||||
diff.diff_history_revisions({ left = list[1], right = list[#list] })
|
||||
end
|
||||
end
|
||||
|
||||
--- Handle describing a log line
|
||||
function M.handle_log_describe()
|
||||
-- Store the cursor pos for when we exit the describe
|
||||
@@ -1128,6 +1148,11 @@ function M.log_keymaps()
|
||||
handler = M.handle_log_tag_set,
|
||||
modes = { "n" },
|
||||
},
|
||||
history = {
|
||||
desc = "Show history diff between revisions (only works with multiple revsets selected)",
|
||||
handler = M.handle_log_history,
|
||||
modes = { "v" },
|
||||
},
|
||||
}
|
||||
|
||||
local merged_keymaps = cmd.merge_keymaps(cmd.resolve_keymaps_from_specs(keymaps, specs), cmd.terminal_keymaps())
|
||||
|
||||
Reference in New Issue
Block a user