diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index eee8d4c..c3c2b58 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2116,6 +2116,7 @@ function! s:Diff(vert,keepfocus,...) abort endif let vert = empty(a:vert) ? s:diff_modifier(2) : a:vert let commit = s:DirCommitFile(@%)[1] + let back = exists('*win_getid') ? 'call win_gotoid(' . win_getid() . ')' : 'wincmd p' if exists(':DiffGitCached') return 'DiffGitCached' elseif (empty(args) || args[0] ==# ':') && commit =~# '^[0-1]\=$' && !empty(s:TreeChomp('ls-files', '--unmerged', '--', s:Relative(''))) @@ -2125,12 +2126,12 @@ function! s:Diff(vert,keepfocus,...) abort execute 'nnoremap dp :diffput '.nr.'diffupdate' let nr2 = bufnr('') call s:diffthis() - wincmd p + exe back execute 'rightbelow '.vert.'split' s:fnameescape(s:Generate(s:Relative(':3:'))) execute 'nnoremap dp :diffput '.nr.'diffupdate' let nr3 = bufnr('') call s:diffthis() - wincmd p + exe back call s:diffthis() execute 'nnoremap d2o :diffget '.nr2.'diffupdate' execute 'nnoremap d3o :diffget '.nr3.'diffupdate' @@ -2175,7 +2176,7 @@ function! s:Diff(vert,keepfocus,...) abort let w:fugitive_diff_restore = restore let winnr = winnr() if getwinvar('#', '&diff') - wincmd p + exe back if !a:keepfocus call feedkeys(winnr."\w", 'n') endif