mirror of
https://github.com/neovim/neovim.git
synced 2025-09-09 12:58:16 +00:00
Merge pull request #19009 from neovim/backport-18820-to-release-0.7
[Backport release-0.7] fix(hl): backport #18820, #18981, #18870
This commit is contained in:
@@ -794,11 +794,11 @@ Dictionary hlattrs2dict(HlAttrs ae, bool use_rgb)
|
|||||||
PUT(hl, "special", INTEGER_OBJ(ae.rgb_sp_color));
|
PUT(hl, "special", INTEGER_OBJ(ae.rgb_sp_color));
|
||||||
}
|
}
|
||||||
} else {
|
} 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));
|
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));
|
PUT(hl, "background", INTEGER_OBJ(ae.cterm_bg_color - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -110,7 +110,8 @@ typedef enum {
|
|||||||
HLF_NFLOAT, // Floating window
|
HLF_NFLOAT, // Floating window
|
||||||
HLF_MSG, // Message area
|
HLF_MSG, // Message area
|
||||||
HLF_BORDER, // Floating window border
|
HLF_BORDER, // Floating window border
|
||||||
HLF_COUNT, // MUST be the last one
|
HLF_CU, // Cursor
|
||||||
|
HLF_COUNT, // MUST be the last one
|
||||||
} hlf_T;
|
} hlf_T;
|
||||||
|
|
||||||
EXTERN const char *hlf_names[] INIT(= {
|
EXTERN const char *hlf_names[] INIT(= {
|
||||||
@@ -170,6 +171,7 @@ EXTERN const char *hlf_names[] INIT(= {
|
|||||||
[HLF_NFLOAT] = "NormalFloat",
|
[HLF_NFLOAT] = "NormalFloat",
|
||||||
[HLF_MSG] = "MsgArea",
|
[HLF_MSG] = "MsgArea",
|
||||||
[HLF_BORDER] = "FloatBorder",
|
[HLF_BORDER] = "FloatBorder",
|
||||||
|
[HLF_CU] = "Cursor",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@@ -735,6 +735,8 @@ void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id)
|
|||||||
g->sg_script_ctx = current_sctx;
|
g->sg_script_ctx = current_sctx;
|
||||||
g->sg_script_ctx.sc_lnum += sourcing_lnum;
|
g->sg_script_ctx.sc_lnum += sourcing_lnum;
|
||||||
|
|
||||||
|
g->sg_attr = hl_get_syn_attr(0, id, attrs);
|
||||||
|
|
||||||
// 'Normal' is special
|
// 'Normal' is special
|
||||||
if (STRCMP(g->sg_name_u, "NORMAL") == 0) {
|
if (STRCMP(g->sg_name_u, "NORMAL") == 0) {
|
||||||
cterm_normal_fg_color = g->sg_cterm_fg;
|
cterm_normal_fg_color = g->sg_cterm_fg;
|
||||||
@@ -744,8 +746,6 @@ void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id)
|
|||||||
normal_sp = g->sg_rgb_sp;
|
normal_sp = g->sg_rgb_sp;
|
||||||
ui_default_colors_set();
|
ui_default_colors_set();
|
||||||
} else {
|
} else {
|
||||||
g->sg_attr = hl_get_syn_attr(0, id, attrs);
|
|
||||||
|
|
||||||
// a cursor style uses this syn_id, make sure its attribute is updated.
|
// a cursor style uses this syn_id, make sure its attribute is updated.
|
||||||
if (cursor_mode_uses_syn_id(id)) {
|
if (cursor_mode_uses_syn_id(id)) {
|
||||||
ui_mode_info_set();
|
ui_mode_info_set();
|
||||||
|
@@ -133,6 +133,13 @@ describe('API: highlight',function()
|
|||||||
eq({ underline = true, standout = true, },
|
eq({ underline = true, standout = true, },
|
||||||
meths.get_hl_by_name('cursorline', 0));
|
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)
|
end)
|
||||||
|
|
||||||
it('nvim_get_hl_id_by_name', function()
|
it('nvim_get_hl_id_by_name', function()
|
||||||
@@ -337,4 +344,10 @@ describe("API: set highlight", function()
|
|||||||
exec_capture('highlight Test_hl3'))
|
exec_capture('highlight Test_hl3'))
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it ("correctly sets 'Normal' internal properties", function()
|
||||||
|
-- Normal has some special handling internally. #18024
|
||||||
|
meths.set_hl(0, 'Normal', {fg='#000083', bg='#0000F3'})
|
||||||
|
eq({foreground = 131, background = 243}, nvim("get_hl_by_name", 'Normal', true))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -212,7 +212,7 @@ describe('ui/cursor', function()
|
|||||||
if m.blinkwait then m.blinkwait = 700 end
|
if m.blinkwait then m.blinkwait = 700 end
|
||||||
end
|
end
|
||||||
if m.hl_id then
|
if m.hl_id then
|
||||||
m.hl_id = 61
|
m.hl_id = 57
|
||||||
m.attr = {background = Screen.colors.DarkGray}
|
m.attr = {background = Screen.colors.DarkGray}
|
||||||
end
|
end
|
||||||
if m.id_lm then m.id_lm = 62 end
|
if m.id_lm then m.id_lm = 62 end
|
||||||
|
Reference in New Issue
Block a user