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
|
" }}}1
|
||||||
" Gdiff {{{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
|
augroup fugitive_diff
|
||||||
autocmd BufWinLeave * if winnr('$') == 2 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | diffoff! | endif
|
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'])
|
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')
|
if exists(':DiffGitCached')
|
||||||
return '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()) !=# ''
|
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
|
diffthis
|
||||||
wincmd p
|
wincmd p
|
||||||
rightbelow vsplit `=fugitive#buffer().repo().translate(s:buffer().expand(':3'))`
|
execute 'rightbelow '.split.' `=fugitive#buffer().repo().translate(s:buffer().expand('':3''))`'
|
||||||
diffthis
|
diffthis
|
||||||
wincmd p
|
wincmd p
|
||||||
diffthis
|
diffthis
|
||||||
@@ -1063,9 +1064,9 @@ function! s:Diff(...) abort
|
|||||||
let spec = s:repo().translate(file)
|
let spec = s:repo().translate(file)
|
||||||
let commit = matchstr(spec,'\C[^:/]//\zs\x\+')
|
let commit = matchstr(spec,'\C[^:/]//\zs\x\+')
|
||||||
if s:buffer().compare_age(commit) < 0
|
if s:buffer().compare_age(commit) < 0
|
||||||
rightbelow vsplit `=spec`
|
execute 'rightbelow '.split.' `=spec`'
|
||||||
else
|
else
|
||||||
leftabove vsplit `=spec`
|
execute 'leftabove '.split.' `=spec`'
|
||||||
endif
|
endif
|
||||||
diffthis
|
diffthis
|
||||||
wincmd p
|
wincmd p
|
||||||
|
|||||||
Reference in New Issue
Block a user