Ensure inactive tabs are force-updated after FocusGained.

On FocusGained the current tab is force-updated.  If there are any other
tabs, we want to make sure they are also force-updated when the user
next switches to them.  To do this we set a flag which is read and
cleared on TabEnter.

See #525.
This commit is contained in:
Andy Stewart
2018-05-29 10:22:03 +01:00
parent a7206c41fc
commit f32eecc4fc

View File

@@ -173,6 +173,16 @@ nnoremap <silent> <Plug>GitGutterPreviewHunk :GitGutterPreviewHunk<CR>
" }}}
function! s:flag_inactive_tabs()
let active_tab = tabpagenr()
let last_tab = tabpagenr('$')
for i in range(1, last_tab)
if i != active_tab
call settabvar(i, 'gitgutter_force', 1)
endif
endfor
endfunction
" Autocommands {{{
augroup gitgutter
@@ -183,7 +193,12 @@ augroup gitgutter
autocmd BufEnter *
\ if exists('t:gitgutter_didtabenter') && t:gitgutter_didtabenter |
\ let t:gitgutter_didtabenter = 0 |
\ call gitgutter#all(!g:gitgutter_terminal_reports_focus) |
\ let force = !g:gitgutter_terminal_reports_focus |
\ if exists('t:gitgutter_force') && t:gitgutter_force |
\ let t:gitgutter_force = 0 |
\ let force = 1 |
\ endif |
\ call gitgutter#all(force) |
\ else |
\ call gitgutter#init_buffer(bufnr('')) |
\ call gitgutter#process_buffer(bufnr(''), !g:gitgutter_terminal_reports_focus) |
@@ -197,7 +212,7 @@ augroup gitgutter
" vim -o file1 file2
autocmd VimEnter * if winnr() != winnr('$') | call gitgutter#all(0) | endif
autocmd FocusGained * call gitgutter#all(1)
autocmd FocusGained * call gitgutter#all(1) | call s:flag_inactive_tabs()
autocmd ColorScheme * call gitgutter#highlight#define_sign_column_highlight() | call gitgutter#highlight#define_highlights()