feat(diffthis): 3 way diff for buffers with conflicts

If the current buffer is marked with conflicts AND the buffer's base is
unset, then diffthis will open a 3 way diff.
This commit is contained in:
Lewis Russell 2022-08-01 16:21:38 +01:00
parent 8b817e76b6
commit 9c3ca02766
2 changed files with 34 additions and 2 deletions

View File

@ -135,7 +135,23 @@ M.diffthis = void(function(base, opts)
if vim.wo.diff then
return
end
run(base, true, opts)
local bufnr = vim.api.nvim_get_current_buf()
local bcache = cache[bufnr]
if not bcache then
return
end
if not base and bcache.git_obj.has_conflicts then
local cwin = api.nvim_get_current_win()
run(':2', true, opts)
api.nvim_set_current_win(cwin)
opts.split = 'belowright'
run(':3', true, opts)
api.nvim_set_current_win(cwin)
else
run(base, true, opts)
end
end)
M.show = void(function(base)

View File

@ -135,7 +135,23 @@ M.diffthis = void(function(base: string, opts: M.DiffthisOpts)
if vim.wo.diff then
return
end
run(base, true, opts)
local bufnr = vim.api.nvim_get_current_buf()
local bcache = cache[bufnr]
if not bcache then
return
end
if not base and bcache.git_obj.has_conflicts then
local cwin = api.nvim_get_current_win()
run(':2', true, opts)
api.nvim_set_current_win(cwin)
opts.split = 'belowright'
run(':3', true, opts)
api.nvim_set_current_win(cwin)
else
run(base, true, opts)
end
end)
M.show = void(function(base: string)