diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index a67f190..ae4de11 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -996,7 +996,7 @@ endfunction " }}}1 " Gdiff {{{1 -call s:command("-bar -nargs=? -complete=customlist,s:EditComplete Gdiff :execute s:Diff()") +call s:command("-bang -bar -nargs=? -complete=customlist,s:EditComplete Gdiff :execute s:Diff(0,)") augroup fugitive_diff autocmd BufWinLeave * if winnr('$') == 2 && &diff && getbufvar(+expand(''), '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