From d81cdacb1e82c5d200e8aee07e0268d2c519160d Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Tue, 16 Oct 2018 10:49:17 +0200 Subject: [PATCH] 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 --- autoload/airline.vim | 8 ++++++++ autoload/airline/highlighter.vim | 5 ----- plugin/airline.vim | 4 +--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/autoload/airline.vim b/autoload/airline.vim index 7d09181..070e98e 100644 --- a/autoload/airline.vim +++ b/autoload/airline.vim @@ -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 diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index 6333e16..2b898c3 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -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) diff --git a/plugin/airline.vim b/plugin/airline.vim index d9307b9..4c752c8 100644 --- a/plugin/airline.vim +++ b/plugin/airline.vim @@ -106,9 +106,7 @@ function! s:airline_toggle() autocmd TerminalOpen * call 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()