Smart choice of vertical or horizontal diff

This commit is contained in:
Tim Pope
2014-06-21 08:18:46 -04:00
parent 0a19a3e78f
commit c5a3c5f8ce
2 changed files with 17 additions and 5 deletions

View File

@@ -1386,7 +1386,7 @@ endfunction
" }}}1
" Gdiff {{{1
call s:command("-bang -bar -nargs=* -complete=customlist,s:EditComplete Gdiff :execute s:Diff(<bang>0,<f-args>)")
call s:command("-bang -bar -nargs=* -complete=customlist,s:EditComplete Gdiff :execute s:Diff(s:diff_horizontal(),<f-args>)")
call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gvdiff :execute s:Diff(0,<f-args>)")
call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gsdiff :execute s:Diff(1,<f-args>)")
@@ -1406,6 +1406,16 @@ augroup fugitive_diff
\ endif
augroup END
function! s:diff_horizontal() abort
if &diffopt =~# 'horizontal' && &diffopt !~# 'vertical'
return 1
elseif &diffopt =~# 'vertical'
return 0
else
return winwidth(0) <= 2 * (&tw ? &tw : 80)
endif
endfunction
function! s:diff_window_count() abort
let c = 0
for nr in range(1,winnr('$'))