christoomey / vim-conflicted

Easy git merge conflict resolution in Vim
MIT License
271 stars 12 forks source link

Update TabEdit to work with latest fugitive.vim #17

Closed anhari closed 2 years ago

anhari commented 5 years ago

Fugitive.vim updated the s:Expand function a few days ago, and I ran into some errors this morning when using vim-conflicted:

Error detected while processing function
/Users/anhari/.vim/bundle/vim-conflicted/plugin/conflicted.vim|14| <SNR>138_Conflicted[4]
/Users/anhari/.vim/bundle/vim-conflicted/plugin/conflicted.vim|21| <SNR>138_Merger[4]
/Users/anhari/.vim/bundle/vim-conflicted/plugin/conflicted.vim|53| <SNR>138_TabEdit[1]
fugitive: Use ':1:%' instead of ':1'
line    4:
fugitive: Use ':2:%' instead of ':2'

I think this should fix things, but might need a closer look since my vimscript is a bit rough :)

christoomey commented 5 years ago

Hi @anhari, thanks for the fix here! Unfortunately, it seems to break things for older versions of fugitive. I tested on tpope/vim-fugitive@ddc5e1a21a9981fd55933dacbb72857de2090bfe and Vim segfaulted (which is impressive, frankly 😄) when I tried to run GitNextConflict. I'm not sure what all is at play there, but ideally, we could have a version of Conflicted that works on any fugitive. Thoughts?

benknoble commented 5 years ago

As far as I have been able to find, fugitive does not expose its version in any way.

One simple-but-hacky fix would be to try/catch the fugitive error. The messages seem to be consistent.

Something like

function! s:TabEdit(parent)
  try
    Gtabedit :1
  catch /fugitive: Use ':[1-3]:%' instead of ':[1-3]'/
    Gtabedit :1:%
  endtry
  let b:conflicted_version = 'base'
  diffthis
  try
    execute 'Gvsplit :' . s:VersionNumber(a:parent)
  catch /fugitive: Use ':[1-3]:%' instead of ':[1-3]'/
    execute 'Gvsplit :' . s:VersionNumber(a:parent) . '.%'
  endtry
  let b:conflicted_version = a:parent
  diffthis
  wincmd r
SevereOverfl0w commented 5 years ago

With the new fugitive, I get a message "Please use Gdiffsplit! for 3-way split" with master & this branch.