mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 22:08:18 +00:00
vim-patch:8.0.0914: highlight attributes are always combined (#10256)
Problem: Highlight attributes are always combined.
Solution: Add the 'nocombine' value to replace attributes instead of
combining them. (scauligi, closes vim/vim#1963)
0cd2a94a40
Closes https://github.com/neovim/neovim/pull/10256.
This commit is contained in:
@@ -4720,18 +4720,19 @@ the same syntax file on all UIs.
|
||||
|
||||
*bold* *underline* *undercurl*
|
||||
*inverse* *italic* *standout*
|
||||
*strikethrough*
|
||||
*nocombine* *strikethrough*
|
||||
cterm={attr-list} *attr-list* *highlight-cterm* *E418*
|
||||
attr-list is a comma separated list (without spaces) of the
|
||||
following items (in any order):
|
||||
bold
|
||||
underline
|
||||
undercurl curly underline
|
||||
strikethrough
|
||||
reverse
|
||||
inverse same as reverse
|
||||
italic
|
||||
standout
|
||||
strikethrough
|
||||
nocombine override attributes instead of combining them
|
||||
NONE no attributes used (used to reset it)
|
||||
|
||||
Note that "bold" can be used here and by using a bold font. They
|
||||
|
@@ -308,8 +308,16 @@ int hl_combine_attr(int char_attr, int prim_attr)
|
||||
// start with low-priority attribute, and override colors if present below.
|
||||
HlAttrs new_en = char_aep;
|
||||
|
||||
if (spell_aep.cterm_ae_attr & HL_NOCOMBINE) {
|
||||
new_en.cterm_ae_attr = spell_aep.cterm_ae_attr;
|
||||
} else {
|
||||
new_en.cterm_ae_attr |= spell_aep.cterm_ae_attr;
|
||||
}
|
||||
if (spell_aep.rgb_ae_attr & HL_NOCOMBINE) {
|
||||
new_en.rgb_ae_attr = spell_aep.rgb_ae_attr;
|
||||
} else {
|
||||
new_en.rgb_ae_attr |= spell_aep.rgb_ae_attr;
|
||||
}
|
||||
|
||||
if (spell_aep.cterm_fg_color > 0) {
|
||||
new_en.cterm_fg_color = spell_aep.cterm_fg_color;
|
||||
|
@@ -18,6 +18,7 @@ typedef enum {
|
||||
HL_UNDERCURL = 0x10,
|
||||
HL_STANDOUT = 0x20,
|
||||
HL_STRIKETHROUGH = 0x40,
|
||||
HL_NOCOMBINE = 0x80,
|
||||
} HlAttrFlags;
|
||||
|
||||
/// Stores a complete highlighting entry, including colors and attributes
|
||||
|
@@ -116,10 +116,10 @@ static int include_link = 0; /* when 2 include "nvim/link" and "clear" */
|
||||
/// following names, separated by commas (but no spaces!).
|
||||
static char *(hl_name_table[]) =
|
||||
{ "bold", "standout", "underline", "undercurl",
|
||||
"italic", "reverse", "inverse", "strikethrough", "NONE" };
|
||||
"italic", "reverse", "inverse", "strikethrough", "nocombine", "NONE" };
|
||||
static int hl_attr_table[] =
|
||||
{ HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE,
|
||||
HL_INVERSE, HL_STRIKETHROUGH, 0 };
|
||||
HL_INVERSE, HL_STRIKETHROUGH, HL_NOCOMBINE, 0 };
|
||||
|
||||
// The patterns that are being searched for are stored in a syn_pattern.
|
||||
// A match item consists of one pattern.
|
||||
|
@@ -438,6 +438,54 @@ describe('highlight', function()
|
||||
})
|
||||
end)
|
||||
|
||||
it('nocombine', function()
|
||||
screen:detach()
|
||||
screen = Screen.new(25,6)
|
||||
screen:set_default_attr_ids{
|
||||
[1] = {foreground = Screen.colors.SlateBlue, underline = true},
|
||||
[2] = {bold = true, foreground = Screen.colors.Blue1},
|
||||
[3] = {underline = true, reverse = true, foreground = Screen.colors.SlateBlue},
|
||||
[4] = {background = Screen.colors.Yellow, reverse = true, foreground = Screen.colors.SlateBlue},
|
||||
[5] = {foreground = Screen.colors.Red},
|
||||
}
|
||||
screen:attach()
|
||||
feed_command('syntax on')
|
||||
feed_command('hi! Underlined cterm=underline gui=underline')
|
||||
feed_command('syn keyword Underlined foobar')
|
||||
feed_command('hi Search cterm=inverse,nocombine gui=inverse,nocombine')
|
||||
insert([[
|
||||
foobar
|
||||
foobar
|
||||
]])
|
||||
screen:expect{grid=[[
|
||||
{1:foobar} |
|
||||
{1:foobar} |
|
||||
^ |
|
||||
{2:~ }|
|
||||
{2:~ }|
|
||||
|
|
||||
]]}
|
||||
|
||||
feed('/foo')
|
||||
screen:expect{grid=[[
|
||||
{3:foo}{1:bar} |
|
||||
{4:foo}{1:bar} |
|
||||
|
|
||||
{2:~ }|
|
||||
{2:~ }|
|
||||
/foo^ |
|
||||
]]}
|
||||
feed('<cr>')
|
||||
screen:expect{grid=[[
|
||||
{4:^foo}{1:bar} |
|
||||
{4:foo}{1:bar} |
|
||||
|
|
||||
{2:~ }|
|
||||
{2:~ }|
|
||||
{5:search hit...uing at TOP} |
|
||||
]]}
|
||||
end)
|
||||
|
||||
it('guisp (special/undercurl)', function()
|
||||
feed_command('syntax on')
|
||||
feed_command('syn keyword TmpKeyword neovim')
|
||||
|
Reference in New Issue
Block a user