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

@@ -278,6 +278,20 @@ describe("API: set highlight", function()
eq(highlight3_result_cterm, meths.get_hl_by_name('Test_hl', false))
end)
it("only allows one underline attribute #22371", function()
local ns = get_ns()
meths.set_hl(ns, 'Test_hl', {
underdouble = true,
underdotted = true,
cterm = {
underline = true,
undercurl = true,
},
})
eq({ undercurl = true }, meths.get_hl_by_name('Test_hl', false))
eq({ underdotted = true }, meths.get_hl_by_name('Test_hl', true))
end)
it("can set a highlight in the global namespace", function()
meths.set_hl(0, 'Test_hl', highlight2_config)
eq('Test_hl xxx cterm=underline,reverse ctermfg=8 ctermbg=15 gui=underline,reverse',