API: nvim_get_hl_by_id: omit hl instead of returning -1 #11685

Problem: When Normal highlight group defines ctermfg/bg, but other
         highlight group lacks ctermfg/bg, nvim_get_hl_by_id(hl_id,
         v:false) returns -1 for the missing ctermfg/bg instead of just
         omitting it.
Solution: checking for -1 in hlattrs2dict()

fix #11680
This commit is contained in:
kevinhwang91
2020-01-08 22:19:23 +08:00
committed by Justin M. Keyes
parent a91ea02830
commit 831fa45ad8
2 changed files with 18 additions and 2 deletions

View File

@@ -642,11 +642,11 @@ Dictionary hlattrs2dict(HlAttrs ae, bool use_rgb)
PUT(hl, "special", INTEGER_OBJ(ae.rgb_sp_color));
}
} else {
if (cterm_normal_fg_color != ae.cterm_fg_color) {
if (cterm_normal_fg_color != ae.cterm_fg_color && ae.cterm_fg_color != 0) {
PUT(hl, "foreground", INTEGER_OBJ(ae.cterm_fg_color - 1));
}
if (cterm_normal_bg_color != ae.cterm_bg_color) {
if (cterm_normal_bg_color != ae.cterm_bg_color && ae.cterm_bg_color != 0) {
PUT(hl, "background", INTEGER_OBJ(ae.cterm_bg_color - 1));
}
}