branch: ignore upcoming FocusGained when updating

closes #2029

airline#util#focusgain(1) was called too soon -- it's called before vim
loses focus and not after it gains focus. Instead, we ignore the next
FocusGained event.
This commit is contained in:
David Briscoe
2020-01-28 12:01:09 -08:00
parent 8fbb16f838
commit dd247a0f85
3 changed files with 14 additions and 10 deletions
+10 -5
View File
@@ -11,7 +11,7 @@ let s:spc = g:airline_symbols.space
let s:nomodeline = (v:version > 703 || (v:version == 703 && has("patch438"))) ? '<nomodeline>' : ''
let s:has_strchars = exists('*strchars')
let s:has_strcharpart = exists('*strcharpart')
let s:focusgained_enabled = 0
let s:focusgained_ignored = 0
" TODO: Try to cache winwidth(0) function
" e.g. store winwidth per window and access that, only update it, if the size
@@ -192,10 +192,15 @@ function! airline#util#stl_disabled(winnr)
\ airline#util#getbufvar(winbufnr(a:winnr), 'airline_disable_statusline', 0)
endfunction
function! airline#util#focusgain(allow)
let s:focusgained_enabled = a:allow
function! airline#util#ignore_next_focusgain()
let s:focusgained_ignored += 1
endfunction
function! airline#util#focusgained_disabled()
return s:focusgained_enabled < 1
function! airline#util#try_focusgained()
let s:focusgained_ignored -= 1
if s:focusgained_ignored < 0
let s:focusgained_ignored = 0
endif
return s:focusgained_ignored <= 0
endfunction