mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 13:23:52 -05:00
Preserve existing 'scrollbind' arrangement with :Gblame
Closes https://github.com/tpope/vim-fugitive/issues/1449 Closes https://github.com/tpope/vim-fugitive/issues/1327
This commit is contained in:
@@ -5157,29 +5157,38 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
|
|||||||
if a:mods =~# '\<tab\>'
|
if a:mods =~# '\<tab\>'
|
||||||
silent tabedit %
|
silent tabedit %
|
||||||
endif
|
endif
|
||||||
|
let bufnr = bufnr('')
|
||||||
|
let temp_state.bufnr = bufnr
|
||||||
|
let restore = []
|
||||||
let mods = substitute(a:mods, '\<tab\>', '', 'g')
|
let mods = substitute(a:mods, '\<tab\>', '', 'g')
|
||||||
for winnr in range(winnr('$'),1,-1)
|
for winnr in range(winnr('$'),1,-1)
|
||||||
if getwinvar(winnr, '&scrollbind')
|
if getwinvar(winnr, '&scrollbind')
|
||||||
call setwinvar(winnr, '&scrollbind', 0)
|
if !&l:scrollbind
|
||||||
|
call setwinvar(winnr, '&scrollbind', 0)
|
||||||
|
elseif winnr != winnr() && getwinvar(winnr, '&foldenable')
|
||||||
|
call setwinvar(winnr, '&foldenable', 0)
|
||||||
|
call add(restore, 'call setwinvar(bufwinnr('.winbufnr(winnr).'),"&foldenable",1)')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
if exists('+cursorbind') && getwinvar(winnr, '&cursorbind')
|
if exists('+cursorbind') && !&l:cursorbind && getwinvar(winnr, '&cursorbind')
|
||||||
call setwinvar(winnr, '&cursorbind', 0)
|
call setwinvar(winnr, '&cursorbind', 0)
|
||||||
endif
|
endif
|
||||||
if s:BlameBufnr(winbufnr(winnr)) > 0
|
if s:BlameBufnr(winbufnr(winnr)) > 0
|
||||||
execute winbufnr(winnr).'bdelete'
|
execute winbufnr(winnr).'bdelete'
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
let bufnr = bufnr('')
|
let restore_winnr = 'bufwinnr(' . bufnr . ')'
|
||||||
let temp_state.bufnr = bufnr
|
if !&l:scrollbind
|
||||||
let restore = 'call setwinvar(bufwinnr('.bufnr.'),"&scrollbind",0)'
|
call add(restore, 'call setwinvar(' . restore_winnr . ',"&scrollbind",0)')
|
||||||
if exists('+cursorbind')
|
endif
|
||||||
let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&cursorbind",0)'
|
if exists('+cursorbind') && !&l:cursorbind
|
||||||
|
call add(restore, 'call setwinvar(' . restore_winnr . ',"&cursorbind",0)')
|
||||||
endif
|
endif
|
||||||
if &l:wrap
|
if &l:wrap
|
||||||
let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&wrap",1)'
|
call add(restore, 'call setwinvar(' . restore_winnr . ',"&wrap",1)')
|
||||||
endif
|
endif
|
||||||
if &l:foldenable
|
if &l:foldenable
|
||||||
let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&foldenable",1)'
|
call add(restore, 'call setwinvar(' . restore_winnr . ',"&foldenable",1)')
|
||||||
endif
|
endif
|
||||||
setlocal scrollbind nowrap nofoldenable
|
setlocal scrollbind nowrap nofoldenable
|
||||||
if exists('+cursorbind')
|
if exists('+cursorbind')
|
||||||
@@ -5188,7 +5197,7 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
|
|||||||
let top = line('w0') + &scrolloff
|
let top = line('w0') + &scrolloff
|
||||||
let current = line('.')
|
let current = line('.')
|
||||||
exe 'silent keepalt' (a:bang ? s:Mods(mods) . 'split' : s:Mods(mods, 'leftabove') . 'vsplit') s:fnameescape(temp)
|
exe 'silent keepalt' (a:bang ? s:Mods(mods) . 'split' : s:Mods(mods, 'leftabove') . 'vsplit') s:fnameescape(temp)
|
||||||
let w:fugitive_leave = restore
|
let w:fugitive_leave = join(restore, '|')
|
||||||
execute top
|
execute top
|
||||||
normal! zt
|
normal! zt
|
||||||
execute current
|
execute current
|
||||||
|
|||||||
Reference in New Issue
Block a user