From 33a633766d72e2f4efe680c0c662d67196941cf3 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Wed, 7 Nov 2018 10:38:34 +0100 Subject: [PATCH] main: do not trigger FocusGained on startup commit f045452743736d53c7471bfb4698fd48569dc1e0 introduced the FocusGained autocommand. Unfortunately, for some systems this might trigger already at startup, resulting in an unwanted redraw that might clear the intro screen. Therefore, add a timer, that enables the FocusGained autocommand after 5 seconds. The 5 seconds is somewhat arbritrarely, but we could change it later if it turns out to be not useable. fixes #1817 --- plugin/airline.vim | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugin/airline.vim b/plugin/airline.vim index 4c752c8f..bfc752cb 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -7,6 +7,7 @@ if &cp || v:version < 702 || (exists('g:loaded_airline') && g:loaded_airline) finish endif let g:loaded_airline = 1 +let s:has_timers = has("timers") let s:airline_initialized = 0 function! s:init() @@ -121,7 +122,16 @@ function! s:airline_toggle() \ | call on_window_changed() \ | endif - autocmd VimResized,FocusGained * unlet! w:airline_lastmode | :call airline_refresh() + autocmd VimResized * unlet! w:airline_lastmode | :call airline_refresh() + if s:has_timers + " do not trigger FocusGained on startup, it might erase the intro + " screen (see #1817) + let Handler=funcref('FocusGainedHandler') + let s:timer=timer_start(5000, Handler) + else + autocmd FocusGained * unlet! w:airline_lastmode | :call airline_refresh() + endif + autocmd TabEnter * :unlet! w:airline_lastmode | let w:airline_active=1 autocmd BufWritePost */autoload/airline/themes/*.vim \ exec 'source '.split(globpath(&rtp, 'autoload/airline/themes/'.g:airline_theme.'.vim', 1), "\n")[0] @@ -163,6 +173,14 @@ function! s:airline_refresh() call airline#update_statusline() endfunction +function! s:FocusGainedHandler(timer) + if exists("s:timer") && a:timer == s:timer + augroup airline + au FocusGained * unlet! w:airline_lastmode | :call airline_refresh() + augroup END + endif +endfu + command! -bar -nargs=? -complete=customlist,get_airline_themes AirlineTheme call airline_theme() command! -bar AirlineToggleWhitespace call airline#extensions#whitespace#toggle() command! -bar AirlineToggle call s:airline_toggle()