Smart choice of vertical or horizontal diff
This commit is contained in:
parent
0a19a3e78f
commit
c5a3c5f8ce
@ -149,14 +149,16 @@ that are part of Git repositories).
|
||||
index is used (which means a three-way diff during a
|
||||
merge conflict, making it a git-mergetool
|
||||
alternative). The newer of the two files is placed
|
||||
to the right. Use |do| and |dp| and write to the
|
||||
index file to simulate "git add --patch".
|
||||
to the right or bottom, depending on 'diffopt' and
|
||||
the width of the window relative to 'textwidth'. Use
|
||||
|do| and |dp| and write to the index file to simulate
|
||||
"git add --patch".
|
||||
|
||||
*fugitive-:Gsdiff*
|
||||
:Gsdiff [revision] Like |:Gdiff|, but split horizontally.
|
||||
:Gsdiff [revision] Like |:Gdiff|, but always split horizontally.
|
||||
|
||||
*fugitive-:Gvdiff*
|
||||
:Gvdiff [revision] Identical to |:Gdiff|. For symmetry with |:Gsdiff|.
|
||||
:Gvdiff [revision] Like |:Gdiff|, but always split vertically.
|
||||
|
||||
*fugitive-:Gmove*
|
||||
:Gmove {destination} Wrapper around git-mv that renames the buffer
|
||||
|
@ -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('$'))
|
||||
|
Loading…
Reference in New Issue
Block a user