:Gdiff! splits horizontally

This commit is contained in:
Tim Pope
2010-04-14 10:48:42 -04:00
parent ccfc60e550
commit 1f0bc8cff9

View File

@@ -996,7 +996,7 @@ endfunction
" }}}1
" Gdiff {{{1
call s:command("-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(<bang>0,<f-args>)")
augroup fugitive_diff
autocmd BufWinLeave * if winnr('$') == 2 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | diffoff! | endif
@@ -1025,14 +1025,15 @@ endfunction
call s:add_methods('buffer',['compare_age'])
function! s:Diff(...) abort
function! s:Diff(bang,...) abort
let split = a:bang ? 'split' : 'vsplit'
if exists(':DiffGitCached')
return 'DiffGitCached'
elseif (!a:0 || a:1 == ':') && s:buffer().commit() =~# '^[0-1]\=$' && s:repo().git_chomp_in_tree('ls-files', '--unmerged', '--', s:buffer().path()) !=# ''
leftabove vsplit `=fugitive#buffer().repo().translate(s:buffer().expand(':2'))`
execute 'leftabove '.split.' `=fugitive#buffer().repo().translate(s:buffer().expand('':2''))`'
diffthis
wincmd p
rightbelow vsplit `=fugitive#buffer().repo().translate(s:buffer().expand(':3'))`
execute 'rightbelow '.split.' `=fugitive#buffer().repo().translate(s:buffer().expand('':3''))`'
diffthis
wincmd p
diffthis
@@ -1063,9 +1064,9 @@ function! s:Diff(...) abort
let spec = s:repo().translate(file)
let commit = matchstr(spec,'\C[^:/]//\zs\x\+')
if s:buffer().compare_age(commit) < 0
rightbelow vsplit `=spec`
execute 'rightbelow '.split.' `=spec`'
else
leftabove vsplit `=spec`
execute 'leftabove '.split.' `=spec`'
endif
diffthis
wincmd p