Fix :Ghdiffsplit with diffopt=vertical
Closes https://github.com/tpope/vim-fugitive/issues/990
This commit is contained in:
parent
cf9ef7377f
commit
c972b2a065
@ -4414,57 +4414,61 @@ function! s:Diff(autodir, keepfocus, mods, ...) abort
|
|||||||
call map(parents, 's:Relative(v:val . ":")')
|
call map(parents, 's:Relative(v:val . ":")')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
if exists('parents') && len(parents) > 1
|
try
|
||||||
let mods = (a:autodir ? s:diff_modifier(len(parents) + 1) : '') . s:Mods(mods, 'leftabove')
|
if &diffopt =~# 'vertical'
|
||||||
let nr = bufnr('')
|
let diffopt = &diffopt
|
||||||
execute mods 'split' s:fnameescape(s:Generate(parents[0]))
|
set diffopt-=vertical
|
||||||
call s:Map('n', 'dp', ':diffput '.nr.'<Bar>diffupdate<CR>', '<silent>')
|
endif
|
||||||
let nr2 = bufnr('')
|
if exists('parents') && len(parents) > 1
|
||||||
call s:diffthis()
|
let mods = (a:autodir ? s:diff_modifier(len(parents) + 1) : '') . s:Mods(mods, 'leftabove')
|
||||||
exe back
|
let nr = bufnr('')
|
||||||
call s:Map('n', 'd2o', ':diffget '.nr2.'<Bar>diffupdate<CR>', '<silent>')
|
execute mods 'split' s:fnameescape(s:Generate(parents[0]))
|
||||||
let mods = substitute(mods, '\Cleftabove\|rightbelow\|aboveleft\|belowright', '\=submatch(0) =~# "f" ? "rightbelow" : "leftabove"', '')
|
|
||||||
for i in range(len(parents)-1, 1, -1)
|
|
||||||
execute mods 'split' s:fnameescape(s:Generate(parents[i]))
|
|
||||||
call s:Map('n', 'dp', ':diffput '.nr.'<Bar>diffupdate<CR>', '<silent>')
|
call s:Map('n', 'dp', ':diffput '.nr.'<Bar>diffupdate<CR>', '<silent>')
|
||||||
let nrx = bufnr('')
|
let nr2 = bufnr('')
|
||||||
call s:diffthis()
|
call s:diffthis()
|
||||||
exe back
|
exe back
|
||||||
call s:Map('n', 'd' . (i + 2) . 'o', ':diffget '.nrx.'<Bar>diffupdate<CR>', '<silent>')
|
call s:Map('n', 'd2o', ':diffget '.nr2.'<Bar>diffupdate<CR>', '<silent>')
|
||||||
endfor
|
let mods = substitute(mods, '\Cleftabove\|rightbelow\|aboveleft\|belowright', '\=submatch(0) =~# "f" ? "rightbelow" : "leftabove"', '')
|
||||||
call s:diffthis()
|
for i in range(len(parents)-1, 1, -1)
|
||||||
return post
|
execute mods 'split' s:fnameescape(s:Generate(parents[i]))
|
||||||
elseif len(args)
|
call s:Map('n', 'dp', ':diffput '.nr.'<Bar>diffupdate<CR>', '<silent>')
|
||||||
let arg = join(args, ' ')
|
let nrx = bufnr('')
|
||||||
if arg ==# ''
|
call s:diffthis()
|
||||||
|
exe back
|
||||||
|
call s:Map('n', 'd' . (i + 2) . 'o', ':diffget '.nrx.'<Bar>diffupdate<CR>', '<silent>')
|
||||||
|
endfor
|
||||||
|
call s:diffthis()
|
||||||
return post
|
return post
|
||||||
elseif arg ==# '/'
|
elseif len(args)
|
||||||
|
let arg = join(args, ' ')
|
||||||
|
if arg ==# ''
|
||||||
|
return post
|
||||||
|
elseif arg ==# '/'
|
||||||
|
let file = s:Relative()
|
||||||
|
elseif arg ==# ':'
|
||||||
|
let file = s:Relative(':0:')
|
||||||
|
elseif arg =~# '^:\d$'
|
||||||
|
let file = s:Relative(arg . ':')
|
||||||
|
else
|
||||||
|
try
|
||||||
|
let file = arg =~# '^:/.' ? fugitive#RevParse(arg) . s:Relative(':') : s:Expand(arg)
|
||||||
|
catch /^fugitive:/
|
||||||
|
return 'echoerr ' . string(v:exception)
|
||||||
|
endtry
|
||||||
|
endif
|
||||||
|
if file !~# ':' && file !~# '^/' && s:TreeChomp('cat-file','-t',file) =~# '^\%(tag\|commit\)$'
|
||||||
|
let file = file.s:Relative(':')
|
||||||
|
endif
|
||||||
|
elseif exists('parents') && len(parents)
|
||||||
|
let file = parents[-1]
|
||||||
|
elseif len(commit)
|
||||||
let file = s:Relative()
|
let file = s:Relative()
|
||||||
elseif arg ==# ':'
|
elseif s:IsConflicted()
|
||||||
let file = s:Relative(':0:')
|
let file = s:Relative(':1:')
|
||||||
elseif arg =~# '^:\d$'
|
let post = 'echohl WarningMsg|echo "Use :Gdiffsplit! for 3 way diff"|echohl NONE|' . post
|
||||||
let file = s:Relative(arg . ':')
|
|
||||||
else
|
else
|
||||||
try
|
let file = s:Relative(':0:')
|
||||||
let file = arg =~# '^:/.' ? fugitive#RevParse(arg) . s:Relative(':') : s:Expand(arg)
|
|
||||||
catch /^fugitive:/
|
|
||||||
return 'echoerr ' . string(v:exception)
|
|
||||||
endtry
|
|
||||||
endif
|
endif
|
||||||
if file !~# ':' && file !~# '^/' && s:TreeChomp('cat-file','-t',file) =~# '^\%(tag\|commit\)$'
|
|
||||||
let file = file.s:Relative(':')
|
|
||||||
endif
|
|
||||||
elseif exists('parents') && len(parents)
|
|
||||||
let file = parents[-1]
|
|
||||||
elseif len(commit)
|
|
||||||
let file = s:Relative()
|
|
||||||
elseif s:IsConflicted()
|
|
||||||
let file = s:Relative(':1:')
|
|
||||||
let post = 'echohl WarningMsg|echo "Use :Gdiffsplit! for 3 way diff"|echohl NONE|' . post
|
|
||||||
else
|
|
||||||
let file = s:Relative(':0:')
|
|
||||||
endif
|
|
||||||
try
|
|
||||||
let spec = s:Generate(file)
|
let spec = s:Generate(file)
|
||||||
let restore = s:diff_restore()
|
let restore = s:diff_restore()
|
||||||
if exists('+cursorbind')
|
if exists('+cursorbind')
|
||||||
@ -4491,6 +4495,10 @@ function! s:Diff(autodir, keepfocus, mods, ...) abort
|
|||||||
return post
|
return post
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr ' . string(v:exception)
|
return 'echoerr ' . string(v:exception)
|
||||||
|
finally
|
||||||
|
if exists('diffopt')
|
||||||
|
let &diffopt = diffopt
|
||||||
|
endif
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user