fix(merge): notify on navigation wrap-around
Problem: goto_next and goto_prev in the merge module wrapped silently when reaching the last or first unresolved hunk. Solution: add vim.notify before the wrap-around jump in both functions.
This commit is contained in:
parent
946724096f
commit
910be50201
2 changed files with 78 additions and 0 deletions
|
|
@ -508,6 +508,44 @@ describe('merge', function()
|
|||
helpers.delete_buffer(w_bufnr)
|
||||
end)
|
||||
|
||||
it('goto_next notifies on wrap-around', function()
|
||||
local working_path = '/tmp/diffs_test_wrap_notify.lua'
|
||||
local w_bufnr = create_working_buffer({
|
||||
'<<<<<<< HEAD',
|
||||
'local x = 1',
|
||||
'=======',
|
||||
'local x = 2',
|
||||
'>>>>>>> feature',
|
||||
}, working_path)
|
||||
|
||||
local d_bufnr = create_diff_buffer({
|
||||
'diff --git a/file.lua b/file.lua',
|
||||
'--- a/file.lua',
|
||||
'+++ b/file.lua',
|
||||
'@@ -1,1 +1,1 @@',
|
||||
'-local x = 1',
|
||||
'+local x = 2',
|
||||
}, working_path)
|
||||
vim.api.nvim_set_current_buf(d_bufnr)
|
||||
vim.api.nvim_win_set_cursor(0, { 6, 0 })
|
||||
|
||||
local notified = false
|
||||
local orig_notify = vim.notify
|
||||
vim.notify = function(msg)
|
||||
if msg:match('wrapped to first hunk') then
|
||||
notified = true
|
||||
end
|
||||
end
|
||||
|
||||
merge.goto_next(d_bufnr)
|
||||
vim.notify = orig_notify
|
||||
|
||||
assert.is_true(notified)
|
||||
|
||||
helpers.delete_buffer(d_bufnr)
|
||||
helpers.delete_buffer(w_bufnr)
|
||||
end)
|
||||
|
||||
it('goto_prev jumps to previous conflict hunk', function()
|
||||
local working_path = '/tmp/diffs_test_prev.lua'
|
||||
local w_bufnr = create_working_buffer({
|
||||
|
|
@ -576,6 +614,44 @@ describe('merge', function()
|
|||
helpers.delete_buffer(w_bufnr)
|
||||
end)
|
||||
|
||||
it('goto_prev notifies on wrap-around', function()
|
||||
local working_path = '/tmp/diffs_test_prev_wrap_notify.lua'
|
||||
local w_bufnr = create_working_buffer({
|
||||
'<<<<<<< HEAD',
|
||||
'local x = 1',
|
||||
'=======',
|
||||
'local x = 2',
|
||||
'>>>>>>> feature',
|
||||
}, working_path)
|
||||
|
||||
local d_bufnr = create_diff_buffer({
|
||||
'diff --git a/file.lua b/file.lua',
|
||||
'--- a/file.lua',
|
||||
'+++ b/file.lua',
|
||||
'@@ -1,1 +1,1 @@',
|
||||
'-local x = 1',
|
||||
'+local x = 2',
|
||||
}, working_path)
|
||||
vim.api.nvim_set_current_buf(d_bufnr)
|
||||
vim.api.nvim_win_set_cursor(0, { 1, 0 })
|
||||
|
||||
local notified = false
|
||||
local orig_notify = vim.notify
|
||||
vim.notify = function(msg)
|
||||
if msg:match('wrapped to last hunk') then
|
||||
notified = true
|
||||
end
|
||||
end
|
||||
|
||||
merge.goto_prev(d_bufnr)
|
||||
vim.notify = orig_notify
|
||||
|
||||
assert.is_true(notified)
|
||||
|
||||
helpers.delete_buffer(d_bufnr)
|
||||
helpers.delete_buffer(w_bufnr)
|
||||
end)
|
||||
|
||||
it('skips resolved hunks', function()
|
||||
local working_path = '/tmp/diffs_test_skip_resolved.lua'
|
||||
local w_bufnr = create_working_buffer({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue