Move CursorMoved autocmd to main augroup

This commit is contained in:
Liam Fleming
2018-06-14 18:31:17 +01:00
parent 45c9621157
commit 11bc0ba843
2 changed files with 10 additions and 12 deletions

View File

@@ -35,15 +35,18 @@ function! s:init()
silent doautocmd User AirlineAfterInit
endfunction
let s:active_winnr = -1
function! s:on_window_changed()
let s:active_winnr = winnr()
if pumvisible() && (!&previewwindow || g:airline_exclude_preview)
return
endif
" Handle each window only once, since we might come here several times for
" different autocommands.
let l:key = [bufnr('%'), winnr(), winnr('$'), tabpagenr(), &ft]
let l:key = [bufnr('%'), s:active_winnr, winnr('$'), tabpagenr(), &ft]
if get(g:, 'airline_last_window_changed', []) == l:key
\ && &stl is# '%!airline#statusline('.winnr().')'
\ && &stl is# '%!airline#statusline('.s:active_winnr.')'
\ && &ft !~? 'gitcommit'
" fugitive is special, it changes names and filetypes several times,
" make sure the caching does not get into its way
@@ -110,6 +113,11 @@ function! s:airline_toggle()
if exists('##CompleteDone')
autocmd CompleteDone * call <sid>on_window_changed()
endif
" non-trivial number of external plugins use eventignore=all, so we need to account for that
autocmd CursorMoved *
\ if winnr() != s:active_winnr
\ | call <sid>on_window_changed()
\ | endif
autocmd VimResized * unlet! w:airline_lastmode | :call <sid>airline_refresh()
autocmd TabEnter * :unlet! w:airline_lastmode | let w:airline_active=1