fix(highlight): avoid ORing underline flags (#22372)

When combining attributes use the one that takes priority.
For :highlight command use the last one specified.
For API use a hard-coded order same as the order in docs.
This commit is contained in:
zeertzjq
2023-02-23 16:15:04 +08:00
committed by GitHub
parent d422fc8274
commit 524e1a0643
5 changed files with 120 additions and 4 deletions

View File

@@ -1124,6 +1124,9 @@ void do_highlight(const char *line, const bool forceit, const bool init)
for (i = ARRAY_SIZE(hl_attr_table); --i >= 0;) {
int len = (int)strlen(hl_name_table[i]);
if (STRNICMP(arg + off, hl_name_table[i], len) == 0) {
if (hl_attr_table[i] & HL_UNDERLINE_MASK) {
attr &= ~HL_UNDERLINE_MASK;
}
attr |= hl_attr_table[i];
off += len;
break;