Check correct window for 'diff' on BufWinLeave

Closes #493.
This commit is contained in:
Tim Pope 2014-05-30 14:26:40 -04:00
parent f8bf95b9ff
commit 416165f063

View File

@ -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('<abuf>'), 'git_dir') !=# '' | call s:diffoff_all(getbufvar(+expand('<abuf>'), 'git_dir')) | endif
autocmd BufWinEnter * if &diff && s:diff_window_count() == 1 && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | call s:diffoff() | endif
autocmd BufWinLeave *
\ if getwinvar(bufwinnr(+expand('<abuf>')), '&diff') &&
\ s:diff_window_count() == 2 &&
\ !empty(getbufvar(+expand('<abuf>'), 'git_dir')) |
\ call s:diffoff_all(getbufvar(+expand('<abuf>'), 'git_dir')) |
\ endif
autocmd BufWinEnter *
\ if getwinvar(bufwinnr(+expand('<abuf>')), '&diff') &&
\ s:diff_window_count() == 1 &&
\ !empty(getbufvar(+expand('<abuf>'), 'git_dir')) |
\ call s:diffoff() |
\ endif
augroup END
function! s:diff_window_count() abort