From 3d313838dbb314e9a785361abe1d2ec7f1ea769e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 6 Mar 2019 15:38:07 +0100 Subject: [PATCH] Only handle FocusGained after FocusLost --- plugin/gitgutter.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index 73dc289..bd478af 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -212,9 +212,16 @@ augroup gitgutter " vim -o file1 file2 autocmd VimEnter * if winnr() != winnr('$') | call gitgutter#all(0) | endif - autocmd FocusGained,ShellCmdPost * call gitgutter#all(1) + autocmd ShellCmdPost * call gitgutter#all(1) autocmd BufLeave term://* call gitgutter#all(1) + " Handle all buffers when focus is gained, but only after it was lost. + " FocusGained gets triggered on startup with Neovim at least already. + " Therefore this tracks also if it was lost before. + let s:focus_was_lost = 0 + autocmd FocusGained * if s:focus_was_lost | let focus_was_lost = 0 | echom 'all!' | call gitgutter#all(1) | endif + autocmd FocusLost * let s:focus_was_lost = 1 + if exists('##VimResume') autocmd VimResume * call gitgutter#all(1) endif