Restore options when turning off diff mode
This commit is contained in:
parent
299a037564
commit
a0f5c0445e
@ -1084,8 +1084,8 @@ 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(getbufvar(+expand('<abuf>'), 'git_dir')) | endif
|
autocmd BufWinLeave * if s:diff_window_count() == 2 && &diff && getbufvar(+expand('<abuf>'), 'git_dir') !=# '' | call s:diffoff_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') !=# '' | call s:diffoff() | endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
function! s:diff_window_count()
|
function! s:diff_window_count()
|
||||||
@ -1096,7 +1096,27 @@ function! s:diff_window_count()
|
|||||||
return c
|
return c
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:diff_off_all(dir)
|
function! s:diffthis()
|
||||||
|
if !&diff
|
||||||
|
let w:fugitive_diff_restore = 'setlocal nodiff noscrollbind'
|
||||||
|
let w:fugitive_diff_restore .= ' scrollopt=' . &l:scrollopt
|
||||||
|
let w:fugitive_diff_restore .= &l:wrap ? ' wrap' : ' nowrap'
|
||||||
|
let w:fugitive_diff_restore .= ' foldmethod=' . &l:foldmethod
|
||||||
|
let w:fugitive_diff_restore .= ' foldcolumn=' . &l:foldcolumn
|
||||||
|
diffthis
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:diffoff()
|
||||||
|
if exists('w:fugitive_diff_restore')
|
||||||
|
execute w:fugitive_diff_restore
|
||||||
|
unlet w:fugitive_diff_restore
|
||||||
|
else
|
||||||
|
diffoff
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:diffoff_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()
|
||||||
@ -1104,7 +1124,7 @@ function! s:diff_off_all(dir)
|
|||||||
let restorewinnr = 1
|
let restorewinnr = 1
|
||||||
endif
|
endif
|
||||||
if exists('b:git_dir') && b:git_dir ==# a:dir
|
if exists('b:git_dir') && b:git_dir ==# a:dir
|
||||||
diffoff
|
call s:diffoff()
|
||||||
endif
|
endif
|
||||||
if exists('restorewinnr')
|
if exists('restorewinnr')
|
||||||
wincmd p
|
wincmd p
|
||||||
@ -1143,13 +1163,13 @@ function! s:Diff(bang,...) abort
|
|||||||
let nr = bufnr('')
|
let nr = bufnr('')
|
||||||
execute 'leftabove '.split.' `=fugitive#buffer().repo().translate(s:buffer().expand('':2''))`'
|
execute 'leftabove '.split.' `=fugitive#buffer().repo().translate(s:buffer().expand('':2''))`'
|
||||||
execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>'
|
execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>'
|
||||||
diffthis
|
call s:diffthis()
|
||||||
wincmd p
|
wincmd p
|
||||||
execute 'rightbelow '.split.' `=fugitive#buffer().repo().translate(s:buffer().expand('':3''))`'
|
execute 'rightbelow '.split.' `=fugitive#buffer().repo().translate(s:buffer().expand('':3''))`'
|
||||||
execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>'
|
execute 'nnoremap <buffer> <silent> dp :diffput '.nr.'<Bar>diffupdate<CR>'
|
||||||
diffthis
|
call s:diffthis()
|
||||||
wincmd p
|
wincmd p
|
||||||
diffthis
|
call s:diffthis()
|
||||||
return ''
|
return ''
|
||||||
elseif a:0
|
elseif a:0
|
||||||
if a:1 ==# ''
|
if a:1 ==# ''
|
||||||
@ -1181,9 +1201,9 @@ function! s:Diff(bang,...) abort
|
|||||||
else
|
else
|
||||||
execute 'leftabove '.split.' `=spec`'
|
execute 'leftabove '.split.' `=spec`'
|
||||||
endif
|
endif
|
||||||
diffthis
|
call s:diffthis()
|
||||||
wincmd p
|
wincmd p
|
||||||
diffthis
|
call s:diffthis()
|
||||||
return ''
|
return ''
|
||||||
catch /^fugitive:/
|
catch /^fugitive:/
|
||||||
return 'echoerr v:errmsg'
|
return 'echoerr v:errmsg'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user