aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-31 07:08:23 +0800
committerGitHub <noreply@github.com>2023-01-31 07:08:23 +0800
commit860fea1a3f880c2da0ac351a9523156bcfc67361 (patch)
tree98289627820327d683aee65a6a9ee73e37f1f9e8
parent27b81af19c498892f4b0444ad29b7be842f8e7b8 (diff)
downloadrneovim-860fea1a3f880c2da0ac351a9523156bcfc67361.tar.gz
rneovim-860fea1a3f880c2da0ac351a9523156bcfc67361.tar.bz2
rneovim-860fea1a3f880c2da0ac351a9523156bcfc67361.zip
fix(highlight): properly deal with underline mask when listing (#22057)
-rw-r--r--src/nvim/highlight.c10
-rw-r--r--src/nvim/highlight_defs.h4
-rw-r--r--src/nvim/highlight_group.c9
-rw-r--r--test/functional/api/highlight_spec.lua6
4 files changed, 17 insertions, 12 deletions
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index 9dab91cc2b..c20eac3c28 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -842,14 +842,14 @@ void hlattrs2dict(Dictionary *dict, HlAttrs ae, bool use_rgb)
PUT_C(hl, "underline", BOOLEAN_OBJ(true));
break;
- case HL_UNDERDOUBLE:
- PUT_C(hl, "underdouble", BOOLEAN_OBJ(true));
- break;
-
case HL_UNDERCURL:
PUT_C(hl, "undercurl", BOOLEAN_OBJ(true));
break;
+ case HL_UNDERDOUBLE:
+ PUT_C(hl, "underdouble", BOOLEAN_OBJ(true));
+ break;
+
case HL_UNDERDOTTED:
PUT_C(hl, "underdotted", BOOLEAN_OBJ(true));
break;
@@ -930,8 +930,8 @@ HlAttrs dict2hlattrs(Dict(highlight) *dict, bool use_rgb, int *link_id, Error *e
CHECK_FLAG(dict, mask, bold, , HL_BOLD);
CHECK_FLAG(dict, mask, italic, , HL_ITALIC);
CHECK_FLAG(dict, mask, underline, , HL_UNDERLINE);
- CHECK_FLAG(dict, mask, underdouble, , HL_UNDERDOUBLE);
CHECK_FLAG(dict, mask, undercurl, , HL_UNDERCURL);
+ CHECK_FLAG(dict, mask, underdouble, , HL_UNDERDOUBLE);
CHECK_FLAG(dict, mask, underdotted, , HL_UNDERDOTTED);
CHECK_FLAG(dict, mask, underdashed, , HL_UNDERDASHED);
CHECK_FLAG(dict, mask, standout, , HL_STANDOUT);
diff --git a/src/nvim/highlight_defs.h b/src/nvim/highlight_defs.h
index a4dcf6eb60..95c81ac9db 100644
--- a/src/nvim/highlight_defs.h
+++ b/src/nvim/highlight_defs.h
@@ -18,8 +18,8 @@ typedef enum {
// The next three bits are all underline styles
HL_UNDERLINE_MASK = 0x38,
HL_UNDERLINE = 0x08,
- HL_UNDERDOUBLE = 0x10,
- HL_UNDERCURL = 0x18,
+ HL_UNDERCURL = 0x10,
+ HL_UNDERDOUBLE = 0x18,
HL_UNDERDOTTED = 0x20,
HL_UNDERDASHED = 0x28,
// 0x30 and 0x38 spare for underline styles
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index 5b1ea9967d..3d91335f55 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -1553,12 +1553,17 @@ static bool highlight_list_arg(const int id, bool didh, const int type, int iarg
} else { // type == LIST_ATTR
buf[0] = NUL;
for (int i = 0; hl_attr_table[i] != 0; i++) {
- if (iarg & hl_attr_table[i]) {
+ if (((hl_attr_table[i] & HL_UNDERLINE_MASK)
+ && ((iarg & HL_UNDERLINE_MASK) == hl_attr_table[i]))
+ || (!(hl_attr_table[i] & HL_UNDERLINE_MASK)
+ && (iarg & hl_attr_table[i]))) {
if (buf[0] != NUL) {
xstrlcat(buf, ",", 100);
}
xstrlcat(buf, hl_name_table[i], 100);
- iarg &= ~hl_attr_table[i]; // don't want "inverse"
+ if (!(hl_attr_table[i] & HL_UNDERLINE_MASK)) {
+ iarg &= ~hl_attr_table[i]; // don't want "inverse"
+ }
}
}
}
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua
index 5941d4c68b..7f044977cb 100644
--- a/test/functional/api/highlight_spec.lua
+++ b/test/functional/api/highlight_spec.lua
@@ -214,7 +214,7 @@ describe("API: set highlight", function()
bold = true,
italic = true,
reverse = true,
- underline = true,
+ underdashed = true,
strikethrough = true,
altfont = true,
cterm = {
@@ -231,7 +231,7 @@ describe("API: set highlight", function()
bold = true,
italic = true,
reverse = true,
- underline = true,
+ underdashed = true,
strikethrough = true,
altfont = true,
}
@@ -297,7 +297,7 @@ describe("API: set highlight", function()
exec_capture('highlight Test_hl'))
meths.set_hl(0, 'Test_hl2', highlight3_config)
- eq('Test_hl2 xxx cterm=italic,reverse,strikethrough,altfont,nocombine ctermfg=8 ctermbg=15 gui=bold,underline,italic,reverse,strikethrough,altfont guifg=#ff0000 guibg=#0032aa',
+ eq('Test_hl2 xxx cterm=italic,reverse,strikethrough,altfont,nocombine ctermfg=8 ctermbg=15 gui=bold,underdashed,italic,reverse,strikethrough,altfont guifg=#ff0000 guibg=#0032aa',
exec_capture('highlight Test_hl2'))
-- Colors are stored with the name they are defined, but