better disabled highlighting for inactive windows on FocusLost

This will make sure that the current window will be highlighted as
expected, even if there are no other windows and all highlighting groups
will be correctly re-created as 'inactive'

references #1807
This commit is contained in:
Christian Brabandt 2018-10-16 10:49:17 +02:00
parent c44bbc66f5
commit d81cdacb1e
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
3 changed files with 9 additions and 8 deletions

View File

@ -115,6 +115,14 @@ function! airline#update_statusline()
call s:invoke_funcrefs(context, g:airline_statusline_funcrefs)
endfunction
function! airline#update_statusline_focuslost()
if get(g:, 'airline_focuslost_inactive', 0)
let bufnr=bufnr('%')
call airline#highlighter#highlight_modified_inactive(bufnr)
call airline#highlighter#highlight(['inactive'], bufnr)
call airline#update_statusline_inactive(range(1, winnr('$')))
endif
endfunction
function! airline#update_statusline_inactive(range)
if airline#util#getwinvar(winnr(), 'airline_disabled', 0)
return

View File

@ -223,11 +223,6 @@ function! airline#highlighter#highlight(modes, ...)
let mapped = map(a:modes, 'v:val == a:modes[0] ? v:val : a:modes[0]."_".v:val')
let suffix = a:modes[0] == 'inactive' ? '_inactive' : ''
for mode in mapped
if mode == 'inactive' && winnr('$') == 1
" there exist no inactive windows, don't need to create all those
" highlighting groups
continue
endif
if exists('g:airline#themes#{g:airline_theme}#palette[mode]')
let dict = g:airline#themes#{g:airline_theme}#palette[mode]
for kvp in items(dict)

View File

@ -106,9 +106,7 @@ function! s:airline_toggle()
autocmd TerminalOpen * call <sid>on_colorscheme_changed()
endif
" Set all statuslines to inactive
autocmd FocusLost * if get(g:, 'airline_focuslost_inactive', 0)|
\ call airline#update_statusline_inactive(range(1, winnr('$')))|
\ endif
autocmd FocusLost * call airline#update_statusline_focuslost()
" Refresh airline for :syntax off
autocmd SourcePre */syntax/syntax.vim
\ call airline#extensions#tabline#buffers#invalidate()