Only :diffoff our own diffs

Closes #395.
This commit is contained in:
Tim Pope 2014-06-21 13:44:44 -04:00
parent 4a77929a32
commit f32bdf1a7b

View File

@ -1408,19 +1408,25 @@ call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gsdiff :execut
augroup fugitive_diff
autocmd!
autocmd BufWinLeave *
\ if getwinvar(bufwinnr(+expand('<abuf>')), '&diff') &&
\ s:diff_window_count() == 2 &&
\ !empty(getbufvar(+expand('<abuf>'), 'git_dir')) |
\ if s:can_diffoff(+expand('<abuf>')) && s:diff_window_count() == 2 |
\ 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')) |
\ if s:can_diffoff(+expand('<abuf>')) && s:diff_window_count() == 1 |
\ call s:diffoff() |
\ endif
augroup END
function! s:can_diffoff(buf) abort
return getwinvar(bufwinnr(a:buf), '&diff') &&
\ !empty(getbufvar(a:buf, 'git_dir')) &&
\ !empty(getwinvar(bufwinnr(a:buf), 'fugitive_diff_restore'))
endfunction
function! fugitive#can_diffoff(buf) abort
return s:can_diffoff(a:buf)
endfunction
function! s:diff_horizontal(count) abort
let fdc = matchstr(&diffopt, 'foldcolumn:\zs\d\+')
if &diffopt =~# 'horizontal' && &diffopt !~# 'vertical'