diff --git a/autoload/airline.vim b/autoload/airline.vim index 36475d1..a7888d1 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -103,14 +103,9 @@ function! airline#update_statusline() if airline#util#getwinvar(winnr(), 'airline_disabled', 0) return endif - for nr in filter(range(1, winnr('$')), 'v:val != winnr()') - if airline#util#getwinvar(nr, 'airline_disabled', 0) - continue - endif - call setwinvar(nr, 'airline_active', 0) - let context = { 'winnr': nr, 'active': 0, 'bufnr': winbufnr(nr) } - call s:invoke_funcrefs(context, s:inactive_funcrefs) - endfor + let range = filter(range(1, winnr('$')), 'v:val != winnr()') + " create inactive statusline + call airline#update_statusline_inactive(range) unlet! w:airline_render_left w:airline_render_right exe 'unlet! ' 'w:airline_section_'. join(s:sections, ' w:airline_section_') @@ -120,6 +115,20 @@ function! airline#update_statusline() call s:invoke_funcrefs(context, g:airline_statusline_funcrefs) endfunction +function! airline#update_statusline_inactive(range) + if airline#util#getwinvar(winnr(), 'airline_disabled', 0) + return + endif + for nr in a:range + if airline#util#getwinvar(nr, 'airline_disabled', 0) + continue + endif + call setwinvar(nr, 'airline_active', 0) + let context = { 'winnr': nr, 'active': 0, 'bufnr': winbufnr(nr) } + call s:invoke_funcrefs(context, s:inactive_funcrefs) + endfor +endfunction + let s:contexts = {} let s:core_funcrefs = [ \ function('airline#extensions#apply'), diff --git a/plugin/airline.vim b/plugin/airline.vim index c32a1bf..386cf7b 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -105,6 +105,8 @@ function! s:airline_toggle() if exists("##TerminalOpen") autocmd TerminalOpen * call on_colorscheme_changed() endif + " Set all statuslines to inactive + autocmd FocusLost * call airline#update_statusline_inactive(range(1, winnr('$'))) " Refresh airline for :syntax off autocmd SourcePre */syntax/syntax.vim \ call airline#extensions#tabline#buffers#invalidate() @@ -119,7 +121,7 @@ function! s:airline_toggle() \ | call on_window_changed() \ | endif - autocmd VimResized * unlet! w:airline_lastmode | :call airline_refresh() + autocmd VimResized,FocusGained * unlet! w:airline_lastmode | :call airline_refresh() 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]