From ebb89a0846ff8b8bc64579155d661b825f97d3f2 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Wed, 13 Jul 2022 20:38:54 +0200 Subject: [PATCH] plugin: mention how to disable certain events E.g. how to disable the FocusGained event by setting the 'eventignore' option. Add some boilerplate to skip the focusgained function handler function, if it should be ignored. (this should in theory stop setting up the autocommands at all so might be tiny performance optimization). closes #2421 --- doc/airline.txt | 5 +++++ plugin/airline.vim | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/airline.txt b/doc/airline.txt index 18b635d4..c9999581 100644 --- a/doc/airline.txt +++ b/doc/airline.txt @@ -2080,6 +2080,11 @@ Q. Performance is bad A. Check the question at the wiki: https://github.com/vim-airline/vim-airline/wiki/FAQ#i-have-a-performance-problem +Q. Something strange happens on certain autocommands +A. Try to disable the autocommand by setting the 'eventignore' option like + this: > + set eventignore+=FocusGained + Solutions to other common problems can be found in the Wiki: diff --git a/plugin/airline.vim b/plugin/airline.vim index 640d8b6e..e2d0d286 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -75,6 +75,10 @@ function! s:on_window_changed(event) endfunction function! s:on_focus_gained() + if &eventignore =~? 'focusgained' + return + endif + if airline#util#try_focusgained() unlet! w:airline_lastmode | :call airline_refresh(1) endif @@ -148,7 +152,7 @@ function! s:airline_toggle() autocmd CursorMoved * call on_cursor_moved() autocmd VimResized * call on_focus_gained() - if exists('*timer_start') && exists('*funcref') + if exists('*timer_start') && exists('*funcref') && &eventignore !~? 'focusgained' " do not trigger FocusGained on startup, it might erase the intro screen (see #1817) " needs funcref() (needs 7.4.2137) and timers (7.4.1578) let Handler=funcref('FocusGainedHandler') @@ -234,7 +238,7 @@ function! s:airline_refresh(...) endfunction function! s:FocusGainedHandler(timer) - if exists("s:timer") && a:timer == s:timer && exists('#airline') + if exists("s:timer") && a:timer == s:timer && exists('#airline') && &eventignore !~? 'focusgained' augroup airline au FocusGained * call s:on_focus_gained() augroup END