Keep alternate file on :Gdiff

Closes #357.
This commit is contained in:
Tim Pope
2014-06-21 11:17:59 -04:00
parent 652c27a46b
commit e3904723f8

View File

@@ -1401,9 +1401,9 @@ endfunction
" Section: Gdiff " Section: Gdiff
call s:command("-bang -bar -nargs=* -complete=customlist,s:EditComplete Gdiff :execute s:Diff('',<f-args>)") call s:command("-bang -bar -nargs=* -complete=customlist,s:EditComplete Gdiff :execute s:Diff('keepalt ',<f-args>)")
call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gvdiff :execute s:Diff('vert ',<f-args>)") call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gvdiff :execute s:Diff('keepalt vert ',<f-args>)")
call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gsdiff :execute s:Diff(' ',<f-args>)") call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gsdiff :execute s:Diff('',<f-args>)")
augroup fugitive_diff augroup fugitive_diff
autocmd! autocmd!
@@ -1422,13 +1422,15 @@ augroup fugitive_diff
augroup END augroup END
function! s:diff_horizontal(count) abort function! s:diff_horizontal(count) abort
let fdc = matchstr(&diffopt, 'foldcolumn:\zs\d\+')
if &diffopt =~# 'horizontal' && &diffopt !~# 'vertical' if &diffopt =~# 'horizontal' && &diffopt !~# 'vertical'
return 'vert ' return 'keepalt vert '
elseif &diffopt =~# 'vertical' elseif &diffopt =~# 'vertical'
return ' ' return 'keepalt '
elseif winwidth(0) <= a:count * ((&tw ? &tw : 80) + (empty(fdc) ? 2 : fdc))
return 'keepalt '
else else
let fdc = matchstr(&diffopt, 'foldcolumn:\zs\d\+') return 'keepalt vert '
return winwidth(0) <= a:count * ((&tw ? &tw : 80) + (empty(fdc) ? 2 : fdc)) ? ' ' : 'vert '
endif endif
endfunction endfunction