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
This commit is contained in:
Christian Brabandt 2022-07-13 20:38:54 +02:00
parent 4a290d16fd
commit ebb89a0846
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
2 changed files with 11 additions and 2 deletions

View File

@ -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:
<https://github.com/vim-airline/vim-airline/wiki/FAQ>

View File

@ -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 <sid>airline_refresh(1)
endif
@ -148,7 +152,7 @@ function! s:airline_toggle()
autocmd CursorMoved * call <sid>on_cursor_moved()
autocmd VimResized * call <sid>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('<sid>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