fix(plines): count 'showbreak' for virtual text at eol

This commit is contained in:
zeertzjq
2023-08-23 11:28:17 +08:00
parent a1d71ad55e
commit 908f247c22
2 changed files with 152 additions and 448 deletions

View File

@ -494,7 +494,10 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
// string at start of line. // string at start of line.
// Do not use 'showbreak' at the NUL after the text. // Do not use 'showbreak' at the NUL after the text.
int head = mb_added; int head = mb_added;
char *const sbr = c == NUL ? empty_option : get_showbreak_value(wp); char *const sbr
// XXX: there should be a better check deeper below
= ((c == NUL && cts->cts_cur_text_width_left + cts->cts_cur_text_width_right == 0)
? empty_option : get_showbreak_value(wp));
if ((*sbr != NUL || wp->w_p_bri) && wp->w_p_wrap) { if ((*sbr != NUL || wp->w_p_bri) && wp->w_p_wrap) {
int col_off_prev = win_col_off(wp); int col_off_prev = win_col_off(wp);
int width2 = wp->w_width_inner - col_off_prev + win_col_off2(wp); int width2 = wp->w_width_inner - col_off_prev + win_col_off2(wp);

View File

@ -1658,7 +1658,7 @@ describe('decorations: inline virtual text', function()
local screen, ns local screen, ns
before_each( function() before_each( function()
clear() clear()
screen = Screen.new(50, 10) screen = Screen.new(50, 3)
screen:attach() screen:attach()
screen:set_default_attr_ids { screen:set_default_attr_ids {
[1] = {bold=true, foreground=Screen.colors.Blue}; [1] = {bold=true, foreground=Screen.colors.Blue};
@ -1689,6 +1689,7 @@ describe('decorations: inline virtual text', function()
it('works', function() it('works', function()
screen:try_resize(50, 10)
insert(example_text) insert(example_text)
feed 'gg' feed 'gg'
screen:expect{grid=[[ screen:expect{grid=[[
@ -1748,6 +1749,7 @@ describe('decorations: inline virtual text', function()
end) end)
it('works with empty chunk', function() it('works with empty chunk', function()
screen:try_resize(50, 10)
insert(example_text) insert(example_text)
feed 'gg' feed 'gg'
screen:expect{grid=[[ screen:expect{grid=[[
@ -1796,21 +1798,12 @@ describe('decorations: inline virtual text', function()
it('cursor positions are correct with multiple inline virtual text', function() it('cursor positions are correct with multiple inline virtual text', function()
insert('12345678') insert('12345678')
meths.buf_set_extmark(0, ns, 0, 4, meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' })
meths.buf_set_extmark(0, ns, 0, 4,
{ virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' })
feed '^' feed '^'
feed '4l' feed '4l'
screen:expect{grid=[[ screen:expect{grid=[[
1234{10: virtual text virtual text }^5678 | 1234{10: virtual text virtual text }^5678 |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -1819,18 +1812,10 @@ describe('decorations: inline virtual text', function()
it('adjusts cursor location correctly when inserting around inline virtual text', function() it('adjusts cursor location correctly when inserting around inline virtual text', function()
insert('12345678') insert('12345678')
feed '$' feed '$'
meths.buf_set_extmark(0, ns, 0, 4, meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' })
screen:expect{grid=[[ screen:expect{grid=[[
1234{10: virtual text }567^8 | 1234{10: virtual text }567^8 |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -1838,18 +1823,10 @@ describe('decorations: inline virtual text', function()
it('has correct highlighting with multi-byte characters', function() it('has correct highlighting with multi-byte characters', function()
insert('12345678') insert('12345678')
meths.buf_set_extmark(0, ns, 0, 4, meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' })
screen:expect{grid=[[ screen:expect{grid=[[
1234{10:múlti-byté chñröcters 修补}567^8 | 1234{10:múlti-byté chñröcters 修补}567^8 |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -1857,33 +1834,18 @@ describe('decorations: inline virtual text', function()
it('has correct cursor position when inserting around virtual text', function() it('has correct cursor position when inserting around virtual text', function()
insert('12345678') insert('12345678')
meths.buf_set_extmark(0, ns, 0, 4, meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
feed '^' feed '^'
feed '3l' feed '3l'
feed 'a' feed 'a'
screen:expect{grid=[[ screen:expect{grid=[[
1234{10:^virtual text}5678 | 1234{10:^virtual text}5678 |
{1:~ }| {1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{8:-- INSERT --} | {8:-- INSERT --} |
]]} ]]}
feed '<ESC>' feed '<ESC>'
screen:expect{grid=[[ screen:expect{grid=[[
123^4{10:virtual text}5678 | 123^4{10:virtual text}5678 |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -1893,43 +1855,27 @@ describe('decorations: inline virtual text', function()
screen:expect{grid=[[ screen:expect{grid=[[
1234{10:^virtual text}5678 | 1234{10:^virtual text}5678 |
{1:~ }| {1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{8:-- INSERT --} | {8:-- INSERT --} |
]]} ]]}
end) end)
it('has correct cursor position with virtual text on an empty line', function() it('has correct cursor position with virtual text on an empty line', function()
meths.buf_set_extmark(0, ns, 0, 0, meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
screen:expect{grid=[[ screen:expect{grid=[[
{10:^virtual text} | {10:^virtual text} |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
end) end)
it('text is drawn correctly with a wrapping virtual text', function() it('text is drawn correctly with a wrapping virtual text', function()
screen:try_resize(50, 8)
feed('o<esc>') feed('o<esc>')
insert([[aaaaaaa insert([[aaaaaaa
bbbbbbb]]) bbbbbbb]])
meths.buf_set_extmark(0, ns, 0, 0, meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('X', 51), 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { string.rep('X', 51), 'Special' } }, virt_text_pos = 'inline' }) meths.buf_set_extmark(0, ns, 2, 0, { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' })
meths.buf_set_extmark(0, ns, 2, 0,
{ virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' })
feed('gg0') feed('gg0')
screen:expect{grid=[[ screen:expect{grid=[[
{10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}|
@ -1938,8 +1884,6 @@ bbbbbbb]])
{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}|
bbbbbbb | bbbbbbb |
{1:~ }| {1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -1952,8 +1896,6 @@ bbbbbbb]])
{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}|
bbbbbbb | bbbbbbb |
{1:~ }| {1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -1966,8 +1908,6 @@ bbbbbbb]])
{10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}|
bbbbbbb | bbbbbbb |
{1:~ }| {1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -1980,8 +1920,6 @@ bbbbbbb]])
{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}|
^bbbbbbb | ^bbbbbbb |
{1:~ }| {1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -1995,8 +1933,6 @@ bbbbbbb]])
bbbbbbb | bbbbbbb |
{1:~ }| {1:~ }|
{1:~ }| {1:~ }|
{1:~ }|
{1:~ }|
{8:-- INSERT --} | {8:-- INSERT --} |
]]} ]]}
end) end)
@ -2028,18 +1964,10 @@ bbbbbbb]])
feed('<TAB>') feed('<TAB>')
feed('test') feed('test')
feed('<ESC>') feed('<ESC>')
meths.buf_set_extmark(0, ns, 0, 1, meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
feed('0') feed('0')
screen:expect{grid=[[ screen:expect{grid=[[
^ {10:virtual text} test | ^ {10:virtual text} test |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2047,13 +1975,6 @@ bbbbbbb]])
feed('l') feed('l')
screen:expect{grid=[[ screen:expect{grid=[[
{10:virtual text} ^ test | {10:virtual text} ^ test |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2061,13 +1982,6 @@ bbbbbbb]])
feed('l') feed('l')
screen:expect{grid=[[ screen:expect{grid=[[
{10:virtual text} ^test | {10:virtual text} ^test |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2075,13 +1989,6 @@ bbbbbbb]])
feed('l') feed('l')
screen:expect{grid=[[ screen:expect{grid=[[
{10:virtual text} t^est | {10:virtual text} t^est |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2089,13 +1996,6 @@ bbbbbbb]])
feed('l') feed('l')
screen:expect{grid=[[ screen:expect{grid=[[
{10:virtual text} te^st | {10:virtual text} te^st |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2105,17 +2005,9 @@ bbbbbbb]])
command('set linebreak') command('set linebreak')
insert('one twoword') insert('one twoword')
feed('0') feed('0')
meths.buf_set_extmark(0, ns, 0, 3, meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' })
screen:expect{grid=[[ screen:expect{grid=[[
^one{10:: virtual text} twoword | ^one{10:: virtual text} twoword |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2131,13 +2023,6 @@ bbbbbbb]])
screen:expect{grid=[[ screen:expect{grid=[[
^foo foo f{10:AAABBB}oo bar | ^foo foo f{10:AAABBB}oo bar |
foo foo f{10:CCCDDD}oo bar | foo foo f{10:CCCDDD}oo bar |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
| |
]]} ]]}
@ -2145,13 +2030,6 @@ bbbbbbb]])
screen:expect{grid=[[ screen:expect{grid=[[
{12:foo} {13:foo} {12:f}{10:AAA}{19:BBB}{12:oo} bar | {12:foo} {13:foo} {12:f}{10:AAA}{19:BBB}{12:oo} bar |
{12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar | {12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
/foo^ | /foo^ |
]]} ]]}
@ -2160,13 +2038,6 @@ bbbbbbb]])
screen:expect{grid=[[ screen:expect{grid=[[
{12:foo} {12:foo} {13:f}{10:AAA}{21:BBB}{13:oo} b{10:EEE}ar | {12:foo} {12:foo} {13:f}{10:AAA}{21:BBB}{13:oo} b{10:EEE}ar |
{12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar | {12:foo} {12:foo} {12:f}{19:CCC}{10:DDD}{12:oo} bar |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
/foo^ | /foo^ |
]]} ]]}
end) end)
@ -2182,13 +2053,6 @@ bbbbbbb]])
screen:expect{grid=[[ screen:expect{grid=[[
foo foo {10:AAABBB}^foo bar | foo foo {10:AAABBB}^foo bar |
foo foo {10:CCCDDD}foo bar | foo foo {10:CCCDDD}foo bar |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
| |
]]} ]]}
@ -2197,13 +2061,6 @@ bbbbbbb]])
screen:expect{grid=[[ screen:expect{grid=[[
foo fo{7:o }{10:AAA}{20:BBB}{7:f}oo bar | foo fo{7:o }{10:AAA}{20:BBB}{7:f}oo bar |
foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo bar | foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo bar |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
@ -2211,13 +2068,6 @@ bbbbbbb]])
screen:expect{grid=[[ screen:expect{grid=[[
foo fo{7:o }{10:AAA}{20:BBB}{7:f}o{10:EEE}o bar | foo fo{7:o }{10:AAA}{20:BBB}{7:f}o{10:EEE}o bar |
foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo bar | foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo bar |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{8:-- VISUAL BLOCK --} | {8:-- VISUAL BLOCK --} |
]]} ]]}
end) end)
@ -2233,13 +2083,6 @@ bbbbbbb]])
screen:expect{grid=[[ screen:expect{grid=[[
foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar |
foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r | foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
| |
]]} ]]}
end) end)
@ -2254,22 +2097,13 @@ bbbbbbb]])
screen:expect{grid=[[ screen:expect{grid=[[
foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar |
foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r | foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
| |
]]} ]]}
end) end)
it('cursor position is correct when inserting around a virtual text with left gravity', function() it('cursor position is correct when inserting around a virtual text with left gravity', function()
screen:try_resize(50, 3)
insert('foo foo foo foo') insert('foo foo foo foo')
meths.buf_set_extmark(0, ns, 0, 8, meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false })
{ virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline', right_gravity = false })
feed('0') feed('0')
feed('8l') feed('8l')
screen:expect{grid=[[ screen:expect{grid=[[
@ -2329,77 +2163,80 @@ bbbbbbb]])
end) end)
it('cursor position is correct when inserting around virtual texts with both left and right gravity', function() it('cursor position is correct when inserting around virtual texts with both left and right gravity', function()
screen:try_resize(50, 3) screen:try_resize(30, 4)
command('setlocal showbreak=+ breakindent breakindentopt=shift:2')
insert('foo foo foo foo') insert('foo foo foo foo')
meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '>>', 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('>'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = false })
meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ '<<', 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('<'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = true })
feed('08l') feed('08l')
screen:expect{grid=[[ screen:expect{grid=[[
foo foo {10:>><<}^foo foo | foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}|
{1:~ }| {1:+}{10:>>>>>>>>>><<<<<<<<<<<<<<<<<}|
{1:+}{10:<<<<<<<<<<<<<<<}^foo foo |
| |
]]} ]]}
feed('i') feed('i')
screen:expect{grid=[[ screen:expect{grid=[[
foo foo {10:>>^<<}foo foo | foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}|
{1:~ }| {1:+}{10:>>>>>>>>>>^<<<<<<<<<<<<<<<<<}|
{1:+}{10:<<<<<<<<<<<<<<<}foo foo |
{8:-- INSERT --} | {8:-- INSERT --} |
]]} ]]}
feed('a') feed('a')
screen:expect{grid=[[ screen:expect{grid=[[
foo foo {10:>>}a{10:^<<}foo foo | foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}|
{1:~ }| {1:+}{10:>>>>>>>>>>}a{10:^<<<<<<<<<<<<<<<<}|
{1:+}{10:<<<<<<<<<<<<<<<<}foo foo |
{8:-- INSERT --} | {8:-- INSERT --} |
]]} ]]}
feed([[<C-\><C-O>]]) feed([[<C-\><C-O>]])
screen:expect{grid=[[ screen:expect{grid=[[
foo foo {10:>>}a{10:<<}^foo foo | foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}|
{1:~ }| {1:+}{10:>>>>>>>>>>}a{10:<<<<<<<<<<<<<<<<}|
{1:+}{10:<<<<<<<<<<<<<<<<}^foo foo |
{8:-- (insert) --} | {8:-- (insert) --} |
]]} ]]}
feed('D') feed('D')
screen:expect{grid=[[ screen:expect{grid=[[
foo foo {10:>>}a{10:^<<} | foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}|
{1:~ }| {1:+}{10:>>>>>>>>>>}a{10:^<<<<<<<<<<<<<<<<}|
{1:+}{10:<<<<<<<<<<<<<<<<} |
{8:-- INSERT --} | {8:-- INSERT --} |
]]} ]]}
feed('<BS>') feed('<BS>')
screen:expect{grid=[[ screen:expect{grid=[[
foo foo {10:>>^<<} | foo foo {10:>>>>>>>>>>>>>>>>>>>>>>}|
{1:~ }| {1:+}{10:>>>>>>>>>>^<<<<<<<<<<<<<<<<<}|
{1:+}{10:<<<<<<<<<<<<<<<} |
{8:-- INSERT --} | {8:-- INSERT --} |
]]} ]]}
feed('<C-U>') feed('<C-U>')
screen:expect{grid=[[ screen:expect{grid=[[
{10:>>^<<} | {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}|
{1:~ }| {1:+}{10:>>^<<<<<<<<<<<<<<<<<<<<<<<<<}|
{1:+}{10:<<<<<<<} |
{8:-- INSERT --} | {8:-- INSERT --} |
]]} ]]}
feed('a') feed('a')
screen:expect{grid=[[ screen:expect{grid=[[
{10:>>}a{10:^<<} | {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}|
{1:~ }| {1:+}{10:>>}a{10:^<<<<<<<<<<<<<<<<<<<<<<<<}|
{1:+}{10:<<<<<<<<} |
{8:-- INSERT --} | {8:-- INSERT --} |
]]} ]]}
feed('<Esc>') feed('<Esc>')
screen:expect{grid=[[ screen:expect{grid=[[
{10:>>}^a{10:<<} | {10:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}|
{1:~ }| {1:+}{10:>>}^a{10:<<<<<<<<<<<<<<<<<<<<<<<<}|
{1:+}{10:<<<<<<<<} |
| |
]]} ]]}
feed('x') feed('x')
screen:expect{grid=[[ screen:expect{grid=[[
{10:^>><<} | {10:^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}|
{1:~ }| {1:+}{10:>><<<<<<<<<<<<<<<<<<<<<<<<<}|
{1:+}{10:<<<<<<<} |
| |
]]} ]]}
end) end)
@ -2407,20 +2244,11 @@ bbbbbbb]])
it('draws correctly with no wrap multiple virtual text, where one is hidden', function() it('draws correctly with no wrap multiple virtual text, where one is hidden', function()
insert('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz') insert('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz')
command("set nowrap") command("set nowrap")
meths.buf_set_extmark(0, ns, 0, 50, meths.buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
meths.buf_set_extmark(0, ns, 0, 2,
{ virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
feed('$') feed('$')
screen:expect{grid=[[ screen:expect{grid=[[
opqrstuvwxyzabcdefghijklmnopqrstuvwx{10:virtual text}y^z| opqrstuvwxyzabcdefghijklmnopqrstuvwx{10:virtual text}y^z|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2429,18 +2257,10 @@ bbbbbbb]])
it('draws correctly with no wrap and a long virtual text', function() it('draws correctly with no wrap and a long virtual text', function()
insert('abcdefghi') insert('abcdefghi')
command("set nowrap") command("set nowrap")
meths.buf_set_extmark(0, ns, 0, 2, meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' })
feed('$') feed('$')
screen:expect{grid=[[ screen:expect{grid=[[
{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i| {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2449,38 +2269,22 @@ bbbbbbb]])
it('tabs are the correct length with no wrap following virtual text', function() it('tabs are the correct length with no wrap following virtual text', function()
command('set nowrap') command('set nowrap')
feed('itest<TAB>a<ESC>') feed('itest<TAB>a<ESC>')
meths.buf_set_extmark(0, ns, 0, 0, meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' })
feed('gg$') feed('gg$')
screen:expect{grid=[[ screen:expect{grid=[[
{10:aaaaaaaaaaaaaaaaaaaaaaaaa}test ^a | {10:aaaaaaaaaaaaaaaaaaaaaaaaa}test ^a |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
end) end)
it('highlighting does not extend when no wrap is enabled with a long virtual text', function() it('highlighting does not extend with no wrap and a long virtual text', function()
insert('abcdef') insert('abcdef')
command("set nowrap") command("set nowrap")
meths.buf_set_extmark(0, ns, 0, 3, meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' })
feed('$') feed('$')
screen:expect{grid=[[ screen:expect{grid=[[
{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f| {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2494,60 +2298,34 @@ bbbbbbb]])
screen:expect{grid=[[ screen:expect{grid=[[
{10:X}{7:abcde}^f | {10:X}{7:abcde}^f |
{1:~ }| {1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{8:-- VISUAL LINE --} | {8:-- VISUAL LINE --} |
]]} ]]}
feed('zl') feed('zl')
screen:expect{grid=[[ screen:expect{grid=[[
{7:abcde}^f | {7:abcde}^f |
{1:~ }| {1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{8:-- VISUAL LINE --} | {8:-- VISUAL LINE --} |
]]} ]]}
feed('zl') feed('zl')
screen:expect{grid=[[ screen:expect{grid=[[
{7:bcde}^f | {7:bcde}^f |
{1:~ }| {1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{8:-- VISUAL LINE --} | {8:-- VISUAL LINE --} |
]]} ]]}
end) end)
it('highlighting is correct when virtual text wraps with number', function() it('highlighting is correct when virtual text wraps with number', function()
screen:try_resize(50, 5)
insert([[ insert([[
test test
test]]) test]])
command('set number') command('set number')
meths.buf_set_extmark(0, ns, 0, 1, meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' })
feed('gg0') feed('gg0')
screen:expect{grid=[[ screen:expect{grid=[[
{2: 1 }^t{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {2: 1 }^t{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}|
{2: }{10:XXXXXXXXXX}est | {2: }{10:XXXXXXXXXX}est |
{2: 2 }test | {2: 2 }test |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2555,32 +2333,17 @@ bbbbbbb]])
it('highlighting is correct when virtual text is proceeded with a match', function() it('highlighting is correct when virtual text is proceeded with a match', function()
insert([[test]]) insert([[test]])
meths.buf_set_extmark(0, ns, 0, 2, meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
feed('gg0') feed('gg0')
command('match ErrorMsg /e/') command('match ErrorMsg /e/')
screen:expect{grid=[[ screen:expect{grid=[[
^t{4:e}{10:virtual text}st | ^t{4:e}{10:virtual text}st |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
command('match ErrorMsg /s/') command('match ErrorMsg /s/')
screen:expect{grid=[[ screen:expect{grid=[[
^te{10:virtual text}{4:s}t | ^te{10:virtual text}{4:s}t |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2588,37 +2351,23 @@ bbbbbbb]])
it('smoothscroll works correctly when virtual text wraps', function() it('smoothscroll works correctly when virtual text wraps', function()
insert('foobar') insert('foobar')
meths.buf_set_extmark(0, ns, 0, 3, meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' })
command('setlocal smoothscroll') command('setlocal smoothscroll')
screen:expect{grid=[[ screen:expect{grid=[[
foo{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| foo{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}|
{10:XXXXXXXX}ba^r | {10:XXXXXXXX}ba^r |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
| |
]]} ]]}
feed('<C-E>') feed('<C-E>')
screen:expect{grid=[[ screen:expect{grid=[[
{1:<<<}{10:XXXXX}ba^r | {1:<<<}{10:XXXXX}ba^r |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
end) end)
it('in diff mode is highlighted correct', function() it('in diff mode is highlighted correct', function()
screen:try_resize(50, 10)
insert([[ insert([[
9000 9000
0009 0009
@ -2673,20 +2422,11 @@ bbbbbbb]])
it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function() it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function()
command('set nowrap') command('set nowrap')
insert('a') insert('a')
meths.buf_set_extmark(0, ns, 0, 0, meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('b', 55), 'Special' } }, virt_text_pos = 'inline' })
meths.buf_set_extmark(0, ns, 0, 0,
{ virt_text = { { string.rep('b', 55), 'Special' } }, virt_text_pos = 'inline' })
feed('$') feed('$')
screen:expect{grid=[[ screen:expect{grid=[[
{10:bbbbbbbbbbbbbbbbbbbbbbbbb}^a | {10:bbbbbbbbbbbbbbbbbbbbbbbbb}^a |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2695,28 +2435,13 @@ bbbbbbb]])
it('correctly draws when overflowing virtual text is followed by TAB with no wrap', function() it('correctly draws when overflowing virtual text is followed by TAB with no wrap', function()
command('set nowrap') command('set nowrap')
feed('i<TAB>test<ESC>') feed('i<TAB>test<ESC>')
meths.buf_set_extmark( meths.buf_set_extmark( 0, ns, 0, 0, { virt_text = { { string.rep('a', 60), 'Special' } }, virt_text_pos = 'inline' })
0,
ns,
0,
0,
{ virt_text = { { string.rep('a', 60), 'Special' } }, virt_text_pos = 'inline' }
)
feed('0') feed('0')
screen:expect({ screen:expect({grid=[[
grid = [[
{10:aaaaaaaaaaaaaaaaaaaaaa} ^ test | {10:aaaaaaaaaaaaaaaaaaaaaa} ^ test |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]], ]]})
})
end) end)
it('does not crash at column 0 when folded in a wide window', function() it('does not crash at column 0 when folded in a wide window', function()
@ -2811,19 +2536,11 @@ bbbbbbb]])
command('set nowrap') command('set nowrap')
command('set list') command('set list')
command('set listchars+=extends:c') command('set listchars+=extends:c')
meths.buf_set_extmark(0, ns, 0, 0, meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline' })
{ virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline' })
insert(string.rep('a', 50)) insert(string.rep('a', 50))
feed('gg0') feed('gg0')
screen:expect{grid=[[ screen:expect{grid=[[
^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:c}| ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:c}|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }| {1:~ }|
| |
]]} ]]}
@ -2832,16 +2549,8 @@ 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\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_pos = 'inline', hl_mode = 'replace' })
virt_text = { { '-口-', 'Special' } }, meths.buf_set_extmark(0, ns, 2, 2, { virt_text = { { '', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' })
virt_text_pos = 'inline',
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 |
@ -2910,16 +2619,8 @@ bbbbbbb]])
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\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_pos = 'inline', hl_mode = 'combine' })
virt_text = { { '-口-', 'Special' } }, meths.buf_set_extmark(0, ns, 2, 2, { virt_text = { { '', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' })
virt_text_pos = 'inline',
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 |