From 7bcfe539beee5fe8c542092732b6fd3786c6080e Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 27 Nov 2020 09:40:22 -0500 Subject: [PATCH] Avoid window shenanigans if :diffoff restores options Closes https://github.com/tpope/vim-fugitive/issues/1634 --- autoload/fugitive.vim | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index cd78697..4a5b108 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -4891,25 +4891,30 @@ function! s:diffthis() abort endfunction function! s:diffoff() abort - if exists('w:fugitive_diff_restore') + if exists('w:fugitive_diff_restore') && v:version < 704 execute w:fugitive_diff_restore - unlet w:fugitive_diff_restore - else - diffoff endif + unlet! w:fugitive_diff_restore + diffoff endfunction function! s:diffoff_all(dir) abort let curwin = winnr() for nr in range(1,winnr('$')) if getwinvar(nr, '&diff') && !empty(getwinvar(nr, 'fugitive_diff_restore')) - if nr != winnr() - execute nr.'wincmd w' + if v:version < 704 + if nr != winnr() + execute nr.'wincmd w' + endif + execute w:fugitive_diff_restore endif - call s:diffoff() + call setwinvar(nr, 'fugitive_diff_restore', '') endif endfor - execute curwin.'wincmd w' + if curwin != winnr() + execute curwin.'wincmd w' + endif + diffoff! endfunction function! s:CompareAge(mine, theirs) abort