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
This commit is contained in:
Christian Brabandt 2017-06-21 09:19:51 +02:00
parent 52c0afadb9
commit 87cdf8f6c4
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09

View File

@ -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=', ''),