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:
parent
52c0afadb9
commit
87cdf8f6c4
@ -59,6 +59,15 @@ function! airline#highlighter#get_highlight2(fg, bg, ...)
|
|||||||
return s:get_array(fg, bg, a:000)
|
return s:get_array(fg, bg, a:000)
|
||||||
endfunction
|
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)
|
function! airline#highlighter#exec(group, colors)
|
||||||
if pumvisible()
|
if pumvisible()
|
||||||
return
|
return
|
||||||
@ -73,7 +82,7 @@ function! airline#highlighter#exec(group, colors)
|
|||||||
call add(colors, '')
|
call add(colors, '')
|
||||||
endif
|
endif
|
||||||
let colors = s:CheckDefined(colors)
|
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',
|
let cmd = printf('hi %s %s %s %s %s %s %s %s',
|
||||||
\ a:group, s:Get(colors, 0, 'guifg=', ''), s:Get(colors, 1, 'guibg=', ''),
|
\ a:group, s:Get(colors, 0, 'guifg=', ''), s:Get(colors, 1, 'guibg=', ''),
|
||||||
\ s:Get(colors, 2, 'ctermfg=', ''), s:Get(colors, 3, 'ctermbg=', ''),
|
\ s:Get(colors, 2, 'ctermfg=', ''), s:Get(colors, 3, 'ctermbg=', ''),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user