mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-12-07 04:34:26 +08:00
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:
@@ -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=', ''),
|
||||
|
||||
Reference in New Issue
Block a user