vim-patch:9.0.1745: Missing test coverage for blockwise Visual highlight (#24790)

Problem:  Missing test coverage for blockwise Visual highlight with
          virtual that starts with a double-width char.
Solution: Add a new virtual text to the test. Some other small fixes.

closes: vim/vim#12835

fc3058495d
This commit is contained in:
zeertzjq 2023-08-19 20:34:58 +08:00 committed by GitHub
parent c8e58bf09c
commit 421713523e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 22 deletions

View File

@ -2831,146 +2831,156 @@ bbbbbbb]])
it('blockwise Visual highlight with double-width virtual text (replace)', function() it('blockwise Visual highlight with double-width virtual text (replace)', function()
screen:try_resize(60, 6) screen:try_resize(60, 6)
insert('123456789\n123456789\n123456789') insert('123456789\n123456789\n123456789\n123456789')
meths.buf_set_extmark(0, ns, 1, 1, { meths.buf_set_extmark(0, ns, 1, 1, {
virt_text = { { '-口-', 'Special' } }, virt_text = { { '-口-', 'Special' } },
virt_text_pos = 'inline', virt_text_pos = 'inline',
hl_mode = 'replace', hl_mode = 'replace',
}) })
meths.buf_set_extmark(0, ns, 2, 2, {
virt_text = { { '', 'Special' } },
virt_text_pos = 'inline',
hl_mode = 'replace',
})
feed('gg0') feed('gg0')
screen:expect{grid=[[ screen:expect{grid=[[
^123456789 | ^123456789 |
1{10:--}23456789 | 1{10:--}23456789 |
12{10:}3456789 |
123456789 | 123456789 |
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
feed('<C-V>2jl') feed('<C-V>3jl')
screen:expect{grid=[[ screen:expect{grid=[[
{7:12}3456789 | {7:12}3456789 |
{7:1}{10:--}23456789 | {7:1}{10:--}23456789 |
{7:12}{10:}3456789 |
{7:1}^23456789 | {7:1}^23456789 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
feed('l') feed('l')
screen:expect{grid=[[ screen:expect{grid=[[
{7:123}456789 | {7:123}456789 |
{7:1}{10:--}23456789 | {7:1}{10:--}23456789 |
{7:12}{10:}3456789 |
{7:12}^3456789 | {7:12}^3456789 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
feed('4l') feed('4l')
screen:expect{grid=[[ screen:expect{grid=[[
{7:1234567}89 | {7:1234567}89 |
{7:1}{10:--}{7:23}456789 | {7:1}{10:--}{7:23}456789 |
{7:12}{10:}{7:345}6789 |
{7:123456}^789 | {7:123456}^789 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
feed('Ol') feed('Ol')
screen:expect{grid=[[ screen:expect{grid=[[
1{7:234567}89 | 1{7:234567}89 |
1{10:--}{7:23}456789 | 1{10:--}{7:23}456789 |
1{7:2}{10:}{7:345}6789 |
1^2{7:34567}89 | 1^2{7:34567}89 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
feed('l') feed('l')
screen:expect{grid=[[ screen:expect{grid=[[
12{7:34567}89 | 12{7:34567}89 |
1{10:--}{7:23}456789 | 1{10:--}{7:23}456789 |
12{10:}{7:345}6789 |
12^3{7:4567}89 | 12^3{7:4567}89 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
feed('l') feed('l')
screen:expect{grid=[[ screen:expect{grid=[[
123{7:4567}89 | 123{7:4567}89 |
1{10:--}{7:23}456789 | 1{10:--}{7:23}456789 |
12{10:}{7:345}6789 |
123^4{7:567}89 | 123^4{7:567}89 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
end) end)
it('blockwise Visual highlight with double-width virtual text (combine)', function() it('blockwise Visual highlight with double-width virtual text (combine)', function()
screen:try_resize(60, 6) screen:try_resize(60, 6)
insert('123456789\n123456789\n123456789') insert('123456789\n123456789\n123456789\n123456789')
meths.buf_set_extmark(0, ns, 1, 1, { meths.buf_set_extmark(0, ns, 1, 1, {
virt_text = { { '-口-', 'Special' } }, virt_text = { { '-口-', 'Special' } },
virt_text_pos = 'inline', virt_text_pos = 'inline',
hl_mode = 'combine', hl_mode = 'combine',
}) })
meths.buf_set_extmark(0, ns, 2, 2, {
virt_text = { { '', 'Special' } },
virt_text_pos = 'inline',
hl_mode = 'combine',
})
feed('gg0') feed('gg0')
screen:expect{grid=[[ screen:expect{grid=[[
^123456789 | ^123456789 |
1{10:--}23456789 | 1{10:--}23456789 |
12{10:}3456789 |
123456789 | 123456789 |
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
feed('<C-V>2jl') feed('<C-V>3jl')
screen:expect{grid=[[ screen:expect{grid=[[
{7:12}3456789 | {7:12}3456789 |
{7:1}{20:-}{10:-}23456789 | {7:1}{20:-}{10:-}23456789 |
{7:12}{10:}3456789 |
{7:1}^23456789 | {7:1}^23456789 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
feed('l') feed('l')
screen:expect{grid=[[ screen:expect{grid=[[
{7:123}456789 | {7:123}456789 |
{7:1}{20:-}{10:-}23456789 | {7:1}{20:-}{10:-}23456789 |
{7:12}{20:}3456789 |
{7:12}^3456789 | {7:12}^3456789 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
feed('4l') feed('4l')
screen:expect{grid=[[ screen:expect{grid=[[
{7:1234567}89 | {7:1234567}89 |
{7:1}{20:--}{7:23}456789 | {7:1}{20:--}{7:23}456789 |
{7:12}{20:}{7:345}6789 |
{7:123456}^789 | {7:123456}^789 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
feed('Ol') feed('Ol')
screen:expect{grid=[[ screen:expect{grid=[[
1{7:234567}89 | 1{7:234567}89 |
1{20:--}{7:23}456789 | 1{20:--}{7:23}456789 |
1{7:2}{20:}{7:345}6789 |
1^2{7:34567}89 | 1^2{7:34567}89 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
feed('l') feed('l')
screen:expect{grid=[[ screen:expect{grid=[[
12{7:34567}89 | 12{7:34567}89 |
1{10:-}{20:-}{7:23}456789 | 1{10:-}{20:-}{7:23}456789 |
12{20:}{7:345}6789 |
12^3{7:4567}89 | 12^3{7:4567}89 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
feed('l') feed('l')
screen:expect{grid=[[ screen:expect{grid=[[
123{7:4567}89 | 123{7:4567}89 |
1{10:-}{20:-}{7:23}456789 | 1{10:-}{20:-}{7:23}456789 |
12{20:}{7:345}6789 |
123^4{7:567}89 | 123^4{7:567}89 |
{1:~ }| {1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
end) end)

View File

@ -345,6 +345,10 @@ func Test_conceal_mouse_click()
redraw redraw
call assert_equal(['conceal click here '], ScreenLines(1, 20)) call assert_equal(['conceal click here '], ScreenLines(1, 20))
" click on the space between "this" and "click" puts cursor there
call Ntest_setmouse(1, 9)
call feedkeys("\<LeftMouse>", "tx")
call assert_equal([0, 1, 13, 0, 13], getcurpos())
" click on 'h' of "here" puts cursor there " click on 'h' of "here" puts cursor there
call Ntest_setmouse(1, 16) call Ntest_setmouse(1, 16)
call feedkeys("\<LeftMouse>", "tx") call feedkeys("\<LeftMouse>", "tx")
@ -371,7 +375,11 @@ func Test_conceal_mouse_click()
call assert_equal([0, 1, 23, 0, 36], getcurpos()) call assert_equal([0, 1, 23, 0, 36], getcurpos())
set virtualedit=all set virtualedit=all
redraw " Nvim: redraw_for_cursorcolumn() redraws for conceal redraw
" click on the space between "this" and "click" puts cursor there
call Ntest_setmouse(1, 9)
call feedkeys("\<LeftMouse>", "tx")
call assert_equal([0, 1, 13, 0, 13], getcurpos())
" click on 'h' of "here" puts cursor there " click on 'h' of "here" puts cursor there
call Ntest_setmouse(1, 16) call Ntest_setmouse(1, 16)
call feedkeys("\<LeftMouse>", "tx") call feedkeys("\<LeftMouse>", "tx")

View File

@ -698,10 +698,9 @@ func Test_colorcolumn_sbr()
let lines =<< trim END let lines =<< trim END
call setline(1, 'The quick brown fox jumped over the lazy dogs') call setline(1, 'The quick brown fox jumped over the lazy dogs')
END END
call writefile(lines, 'Xtest_colorcolumn_srb', 'D') call writefile(lines, 'Xtest_colorcolumn_sbr', 'D')
let buf = RunVimInTerminal('-S Xtest_colorcolumn_srb', {'rows': 10,'columns': 40}) let buf = RunVimInTerminal('-S Xtest_colorcolumn_sbr', {'rows': 10,'columns': 40})
call term_sendkeys(buf, ":set co=40 showbreak=+++>\\ cc=40,41,43\<CR>") call term_sendkeys(buf, ":set co=40 showbreak=+++>\\ cc=40,41,43\<CR>")
call TermWait(buf)
call VerifyScreenDump(buf, 'Test_colorcolumn_3', {}) call VerifyScreenDump(buf, 'Test_colorcolumn_3', {})
" clean up " clean up