mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-14 14:23:51 -05:00
Focus correct window after gq in :Git blame
Resolves: https://github.com/tpope/vim-fugitive/issues/770
This commit is contained in:
@@ -6767,8 +6767,12 @@ function! s:BlameCommitFileLnum(...) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:BlameLeave() abort
|
function! s:BlameLeave() abort
|
||||||
let bufwinnr = bufwinnr(s:BlameBufnr())
|
let state = s:TempState()
|
||||||
if bufwinnr > 0
|
let bufwinnr = win_id2win(get(state, 'origin_winid'))
|
||||||
|
if bufwinnr == 0
|
||||||
|
let bufwinnr = bufwinnr(get(state, 'origin_bufnr', -1))
|
||||||
|
endif
|
||||||
|
if get(state, 'filetype', '') ==# 'fugitiveblame' && bufwinnr > 0
|
||||||
let bufnr = bufnr('')
|
let bufnr = bufnr('')
|
||||||
exe bufwinnr . 'wincmd w'
|
exe bufwinnr . 'wincmd w'
|
||||||
return bufnr . 'bdelete'
|
return bufnr . 'bdelete'
|
||||||
@@ -6961,8 +6965,10 @@ 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.origin_bufnr = bufnr('')
|
||||||
let temp_state.origin_bufnr = bufnr
|
if exists('*win_getid')
|
||||||
|
let temp_state.origin_winid = win_getid()
|
||||||
|
endif
|
||||||
let restore = []
|
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)
|
||||||
@@ -6975,11 +6981,11 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
let win_blame_bufnr = s:BlameBufnr(winbufnr(winnr))
|
let win_blame_bufnr = s:BlameBufnr(winbufnr(winnr))
|
||||||
if getwinvar(winnr, '&scrollbind') ? win_blame_bufnr == bufnr : win_blame_bufnr > 0
|
if getwinvar(winnr, '&scrollbind') ? win_blame_bufnr == temp_state.origin_bufnr : win_blame_bufnr > 0
|
||||||
execute winbufnr(winnr).'bdelete'
|
execute winbufnr(winnr).'bdelete'
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
let restore_winnr = exists('*win_getid') ? win_getid() : 'bufwinnr(' . bufnr . ')'
|
let restore_winnr = get(temp_state, 'origin_winid', 'bufwinnr(' . temp_state.origin_bufnr . ')')
|
||||||
if !&l:scrollbind
|
if !&l:scrollbind
|
||||||
call add(restore, 'call setwinvar(' . restore_winnr . ',"&scrollbind",0)')
|
call add(restore, 'call setwinvar(' . restore_winnr . ',"&scrollbind",0)')
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user