Mitigate conflict with DirDiff plugin

This plugin tries to be helpful about disabling diff mode when a diff
window closes, which was confusing DirDiff. We can mitigate that but
only disabling diff mode when b:git_dir matches.
This commit is contained in:
Tim Pope
2010-11-13 20:26:53 -05:00
parent a5e9b2e93e
commit affce710e2

View File

@@ -1013,7 +1013,7 @@ call s:command("-bar -nargs=? -complete=customlist,s:EditComplete Gsdiff :execut
augroup fugitive_diff augroup fugitive_diff
autocmd! autocmd!
autocmd BufWinLeave * if s:diff_window_count() == 2 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | call s:diff_off_all() | endif autocmd BufWinLeave * if s:diff_window_count() == 2 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | call s:diff_off_all(getbufvar(+expand('<abuf>'), 'git_dir')) | endif
autocmd BufWinEnter * if s:diff_window_count() == 1 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | diffoff | endif autocmd BufWinEnter * if s:diff_window_count() == 1 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | diffoff | endif
augroup END augroup END
@@ -1025,14 +1025,16 @@ function! s:diff_window_count()
return c return c
endfunction endfunction
function! s:diff_off_all() function! s:diff_off_all(dir)
for nr in range(1,winnr('$')) for nr in range(1,winnr('$'))
if getwinvar(nr,'&diff') if getwinvar(nr,'&diff')
if nr != winnr() if nr != winnr()
execute nr.'wincmd w' execute nr.'wincmd w'
let restorewinnr = 1 let restorewinnr = 1
endif endif
diffoff if exists('b:git_dir') && b:git_dir ==# a:dir
diffoff
endif
if exists('restorewinnr') if exists('restorewinnr')
wincmd p wincmd p
endif endif