diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index 24aa6fa4..f5e68465 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -3,6 +3,7 @@ let s:is_win32term = (has('win32') || has('win64')) && !has('gui_running') let s:separators = {} +let s:accents = {} function! s:gui2cui(rgb, fallback) if a:rgb == '' @@ -94,6 +95,10 @@ function! airline#highlighter#add_separator(from, to, inverse) call exec_separator({}, a:from, a:to, a:inverse, '') endfunction +function! airline#highlighter#add_accent(accent) + let s:accents[a:accent] = 1 +endfunction + function! airline#highlighter#highlight_modified_inactive(bufnr) if getbufvar(a:bufnr, '&modified') let colors = exists('g:airline#themes#{g:airline_theme}#palette.inactive_modified.airline_c') @@ -121,7 +126,10 @@ function! airline#highlighter#highlight(modes) let mode_colors = kvp[1] call airline#highlighter#exec(kvp[0].suffix, mode_colors) - for accent in keys(p.accents) + for accent in keys(s:accents) + if !has_key(p.accents, accent) + continue + endif let colors = copy(mode_colors) if p.accents[accent][0] != '' let colors[0] = p.accents[accent][0] diff --git a/autoload/airline/section.vim b/autoload/airline/section.vim index aba88a05..4562bacd 100644 --- a/autoload/airline/section.vim +++ b/autoload/airline/section.vim @@ -6,6 +6,7 @@ let s:spc = g:airline_symbols.space function! s:wrap_accent(part, value) if exists('a:part.accent') + call airline#highlighter#add_accent(a:part.accent) return '%#__accent_'.(a:part.accent).'#'.a:value.'%#__restore__#' endif return a:value diff --git a/t/highlighter.vim b/t/highlighter.vim index 0a10c19f..a1ed4905 100644 --- a/t/highlighter.vim +++ b/t/highlighter.vim @@ -13,6 +13,7 @@ describe 'highlighter' Expect exists('g:airline#themes#dark#palette.normal.airline_c_red') to_be_false Expect hlID('airline_c_red') == 0 call airline#themes#patch(g:airline#themes#dark#palette) + call airline#highlighter#add_accent('red') call airline#highlighter#highlight(['normal']) Expect hlID('airline_c_red') != 0 end