From 87cdf8f6c42d4560f69dfc70370ba02e659bc60c Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Wed, 21 Jun 2017 09:19:51 +0200 Subject: [PATCH] highlighter: Make sure hi group exists and is valid previously we only checked, that the group exists, however if loading a new color scheme, this might lead to the group becoming cleared. That means it still exists, but the highlighting group would not show anything. Therefore, also check that the group is not cleared. closes #1483 --- autoload/airline/highlighter.vim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index 16ae66ef..8c1da3bf 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -59,6 +59,15 @@ function! airline#highlighter#get_highlight2(fg, bg, ...) return s:get_array(fg, bg, a:000) endfunction +function! s:hl_group_exists(group) + if !hlexists(a:group) + return 0 + elseif empty(synIDattr(hlID(a:group), 'fg')) + return 0 + endif + return 1 +endfunction + function! airline#highlighter#exec(group, colors) if pumvisible() return @@ -73,7 +82,7 @@ function! airline#highlighter#exec(group, colors) call add(colors, '') endif let colors = s:CheckDefined(colors) - if old_hi != colors || !hlexists(a:group) + if old_hi != colors || !s:hl_group_exists(a:group) let cmd = printf('hi %s %s %s %s %s %s %s %s', \ a:group, s:Get(colors, 0, 'guifg=', ''), s:Get(colors, 1, 'guibg=', ''), \ s:Get(colors, 2, 'ctermfg=', ''), s:Get(colors, 3, 'ctermbg=', ''),