Skip to content
forked from neovim/neovim

Commit

Permalink
fix(hl): return cterm fg/bg even if they match Normal neovim#18981
Browse files Browse the repository at this point in the history
Fixes neovim#18980

- 831fa45 is related but this doesn't regress that
- The `cterm_normal_fg_color != ae.cterm_fg_color` comparison is originally
  carried from patch to patch starting all the way back in 29bc6df where it
  was avoiding setting a HL attr. But `hlattrs2dict()` now is just
  informational.
  • Loading branch information
rktjmp authored and clason committed Jun 18, 2022
1 parent ee210b0 commit f70e083
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/nvim/highlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,11 +794,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 && ae.cterm_fg_color != 0) {
if (ae.cterm_fg_color != 0) {
PUT(hl, "foreground", INTEGER_OBJ(ae.cterm_fg_color - 1));
}

if (cterm_normal_bg_color != ae.cterm_bg_color && ae.cterm_bg_color != 0) {
if (ae.cterm_bg_color != 0) {
PUT(hl, "background", INTEGER_OBJ(ae.cterm_bg_color - 1));
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/functional/api/highlight_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ describe('API: highlight',function()
eq({ underline = true, standout = true, },
meths.get_hl_by_name('cursorline', 0));

-- Test cterm & Normal values. #18024 (tail) & #18980
-- Ensure Normal, and groups that match Normal return their fg & bg cterm values
meths.set_hl(0, 'Normal', {ctermfg = 17, ctermbg = 213})
meths.set_hl(0, 'NotNormal', {ctermfg = 17, ctermbg = 213})
-- Note colors are "cterm" values, not rgb-as-ints
eq({foreground = 17, background = 213}, nvim("get_hl_by_name", 'Normal', false))
eq({foreground = 17, background = 213}, nvim("get_hl_by_name", 'NotNormal', false))
end)

it('nvim_get_hl_id_by_name', function()
Expand Down

0 comments on commit f70e083

Please sign in to comment.