mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 05:43:52 -05:00
:Gdiff! splits horizontally
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user