From 416165f0630f683b859fd56161183ca3d6eecc44 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 30 May 2014 14:26:40 -0400 Subject: [PATCH] Check correct window for 'diff' on BufWinLeave Closes #493. --- plugin/fugitive.vim | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 6b64bca..fc5cc4f 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1392,8 +1392,18 @@ call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gsdiff :execut augroup fugitive_diff autocmd! - autocmd BufWinLeave * if &diff && s:diff_window_count() == 2 && getbufvar(+expand(''), 'git_dir') !=# '' | call s:diffoff_all(getbufvar(+expand(''), 'git_dir')) | endif - autocmd BufWinEnter * if &diff && s:diff_window_count() == 1 && getbufvar(+expand(''), 'git_dir') !=# '' | call s:diffoff() | endif + autocmd BufWinLeave * + \ if getwinvar(bufwinnr(+expand('')), '&diff') && + \ s:diff_window_count() == 2 && + \ !empty(getbufvar(+expand(''), 'git_dir')) | + \ call s:diffoff_all(getbufvar(+expand(''), 'git_dir')) | + \ endif + autocmd BufWinEnter * + \ if getwinvar(bufwinnr(+expand('')), '&diff') && + \ s:diff_window_count() == 1 && + \ !empty(getbufvar(+expand(''), 'git_dir')) | + \ call s:diffoff() | + \ endif augroup END function! s:diff_window_count() abort