diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-02-23 16:15:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-23 16:15:04 +0800 |
commit | 524e1a06432ed7a88c1e183d81812dd48dc18cfb (patch) | |
tree | 3964961f56feece9b1e306966fb9f17e166259f2 /test/functional/ui/decorations_spec.lua | |
parent | d422fc8274e757e95329e60b4e6daec59363ba19 (diff) | |
download | rneovim-524e1a06432ed7a88c1e183d81812dd48dc18cfb.tar.gz rneovim-524e1a06432ed7a88c1e183d81812dd48dc18cfb.tar.bz2 rneovim-524e1a06432ed7a88c1e183d81812dd48dc18cfb.zip |
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.
Diffstat (limited to 'test/functional/ui/decorations_spec.lua')
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 6ed32a8cd4..4759d68200 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1045,6 +1045,83 @@ end]] end) + it('underline attribute with higher priority takes effect #22371', function() + screen:try_resize(50, 3) + insert('aaabbbaaa') + exec([[ + hi TestUL gui=underline guifg=Blue + hi TestUC gui=undercurl guisp=Red + hi TestBold gui=bold + ]]) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}; + [1] = {underline = true, foreground = Screen.colors.Blue}; + [2] = {undercurl = true, special = Screen.colors.Red}; + [3] = {underline = true, foreground = Screen.colors.Blue, special = Screen.colors.Red}; + [4] = {undercurl = true, foreground = Screen.colors.Blue, special = Screen.colors.Red}; + [5] = {bold = true, underline = true, foreground = Screen.colors.Blue}; + [6] = {bold = true, undercurl = true, special = Screen.colors.Red}; + }) + + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 20 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 30 }) + screen:expect([[ + {1:aaa}{4:bbb}{1:aa^a} | + {0:~ }| + | + ]]) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 20 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 30 }) + screen:expect([[ + {2:aaa}{3:bbb}{2:aa^a} | + {0:~ }| + | + ]]) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 30 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 20 }) + screen:expect([[ + {1:aaa}{3:bbb}{1:aa^a} | + {0:~ }| + | + ]]) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 30 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 20 }) + screen:expect([[ + {2:aaa}{4:bbb}{2:aa^a} | + {0:~ }| + | + ]]) + + -- When only one highlight group has an underline attribute, it should always take effect. + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 20 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 30 }) + screen:expect([[ + {1:aaa}{5:bbb}{1:aa^a} | + {0:~ }| + | + ]]) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 30 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 20 }) + screen:expect_unchanged(true) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 20 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 30 }) + screen:expect([[ + {2:aaa}{6:bbb}{2:aa^a} | + {0:~ }| + | + ]]) + meths.buf_clear_namespace(0, ns, 0, -1) + meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 30 }) + meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 20 }) + screen:expect_unchanged(true) + end) + end) describe('decorations: virtual lines', function() |