test(extmarks): add tests for #14201 #20004 #20885 (#23794)

This commit is contained in:
zeertzjq 2023-05-28 16:28:10 +08:00 committed by GitHub
parent ddd92a70d2
commit f29acc5073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 74 additions and 8 deletions

View File

@ -8,6 +8,7 @@ local exec_lua = helpers.exec_lua
local exec = helpers.exec
local expect_events = helpers.expect_events
local meths = helpers.meths
local funcs = helpers.funcs
local curbufmeths = helpers.curbufmeths
local command = helpers.command
local assert_alive = helpers.assert_alive
@ -651,7 +652,7 @@ describe('extmark decorations', function()
[16] = {blend = 30, background = Screen.colors.Red1, foreground = Screen.colors.Magenta1};
[17] = {bold = true, foreground = Screen.colors.Brown, background = Screen.colors.LightGrey};
[18] = {background = Screen.colors.LightGrey};
[19] = {foreground = Screen.colors.Cyan4, background = Screen.colors.LightGrey};
[19] = {foreground = Screen.colors.DarkCyan, background = Screen.colors.LightGrey};
[20] = {foreground = tonumber('0x180606'), background = tonumber('0xf13f3f')};
[21] = {foreground = Screen.colors.Gray0, background = tonumber('0xf13f3f')};
[22] = {foreground = tonumber('0xb20000'), background = tonumber('0xf13f3f')};
@ -662,6 +663,9 @@ describe('extmark decorations', function()
[27] = {background = Screen.colors.Plum1};
[28] = {underline = true, foreground = Screen.colors.SlateBlue};
[29] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightGray, underline = true};
[30] = {foreground = Screen.colors.DarkCyan, background = Screen.colors.LightGray, underline = true};
[31] = {underline = true, foreground = Screen.colors.DarkCyan};
[32] = {underline = true};
}
ns = meths.create_namespace 'test'
@ -1367,7 +1371,56 @@ describe('extmark decorations', function()
screen:expect_unchanged(true)
end)
it('highlights the beginning of a TAB char correctly', function()
it('highlight is combined with syntax and sign linehl #20004', function()
screen:try_resize(50, 3)
insert([[
function Func()
end]])
feed('gg')
command('set ft=lua')
command('syntax on')
meths.buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_mode = 'combine', hl_group = 'Visual' })
command('hi default MyLine gui=underline')
command('sign define CurrentLine linehl=MyLine')
funcs.sign_place(6, 'Test', 'CurrentLine', '', { lnum = 1 })
screen:expect{grid=[[
{30:^fun}{31:ction}{32: Func() }|
{6:end} |
|
]]}
end)
it('highlight works after TAB with sidescroll #14201', function()
screen:try_resize(50, 3)
command('set nowrap')
meths.buf_set_lines(0, 0, -1, true, {'\tword word word word'})
meths.buf_set_extmark(0, ns, 0, 1, { end_col = 3, hl_group = 'ErrorMsg' })
screen:expect{grid=[[
^ {4:wo}rd word word word |
{1:~ }|
|
]]}
feed('7zl')
screen:expect{grid=[[
{4:^wo}rd word word word |
{1:~ }|
|
]]}
feed('zl')
screen:expect{grid=[[
{4:^wo}rd word word word |
{1:~ }|
|
]]}
feed('zl')
screen:expect{grid=[[
{4:^o}rd word word word |
{1:~ }|
|
]]}
end)
it('highlights the beginning of a TAB char correctly #23734', function()
screen:try_resize(50, 3)
meths.buf_set_lines(0, 0, -1, true, {'this is the\ttab'})
meths.buf_set_extmark(0, ns, 0, 11, { end_col = 15, hl_group = 'ErrorMsg' })
@ -1386,7 +1439,20 @@ describe('extmark decorations', function()
]]}
end)
pending('highlight applies to a full Tab in visual block mode #23734', function()
it('highlight applies to a full TAB on line with matches #20885', function()
screen:try_resize(50, 3)
meths.buf_set_lines(0, 0, -1, true, {'\t-- match1', ' -- match2'})
funcs.matchadd('Underlined', 'match')
meths.buf_set_extmark(0, ns, 0, 0, { end_row = 1, end_col = 0, hl_group = 'Visual' })
meths.buf_set_extmark(0, ns, 1, 0, { end_row = 2, end_col = 0, hl_group = 'Visual' })
screen:expect{grid=[[
{18: ^ -- }{29:match}{18:1} |
{18: -- }{29:match}{18:2} |
|
]]}
end)
pending('highlight applies to a full TAB in visual block mode', function()
screen:try_resize(50, 8)
meths.buf_set_lines(0, 0, -1, true, {'asdf', '\tasdf', '\tasdf', '\tasdf', 'asdf'})
meths.buf_set_extmark(0, ns, 0, 0, {end_row = 5, end_col = 0, hl_group = 'Underlined'})
@ -2193,7 +2259,7 @@ describe('decorations: virtual lines', function()
screen:attach()
screen:set_default_attr_ids {
[1] = {bold=true, foreground=Screen.colors.Blue};
[2] = {foreground = Screen.colors.Cyan4};
[2] = {foreground = Screen.colors.DarkCyan};
[3] = {background = Screen.colors.Yellow1};
[4] = {bold = true};
[5] = {background = Screen.colors.Yellow, foreground = Screen.colors.Blue};

View File

@ -426,7 +426,7 @@ describe('highlight', function()
^ |
{2:~ }|
|
]],{
]], {
[1] = {strikethrough = true},
[2] = {bold = true, foreground = Screen.colors.Blue1},
})
@ -515,7 +515,7 @@ describe('highlight', function()
{1:neovim} tabbed^ |
{0:~ }|
{5:-- INSERT --} |
]],{
]], {
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {background = Screen.colors.Yellow, foreground = Screen.colors.Red,
special = Screen.colors.Red},
@ -527,7 +527,7 @@ describe('highlight', function()
end)
it("'diff', syntax and extmark", function()
it("'diff', syntax and extmark #23722", function()
local screen = Screen.new(25,10)
screen:attach()
exec([[
@ -549,7 +549,7 @@ describe('highlight', function()
{4:~ }|
{8:[No Name] }|
|
]],{
]], {
[0] = {Screen.colors.WebGray, foreground = Screen.colors.DarkBlue},
[1] = {background = Screen.colors.Grey, foreground = Screen.colors.Blue4},
[2] = {foreground = Screen.colors.Red, background = Screen.colors.LightBlue},