vim-patch:9.1.1798: Wrong display with 'sms' and long wrapped virt text at EOL (#35930)

Problem:  Wrong display with 'smoothscroll' and long wrapped virtual
          text at EOL.
Solution: Handle w_skipcol inside long wrapped virtual text at EOL
          (zeertzjq).

closes: vim/vim#18408

d9318acc02
This commit is contained in:
zeertzjq
2025-09-27 21:28:40 +08:00
parent 958a5ef2e6
commit 4db62d96bc
2 changed files with 164 additions and 13 deletions

View File

@@ -1458,10 +1458,13 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, b
csarg.max_head_vcol = start_col; csarg.max_head_vcol = start_col;
int vcol = wlv.vcol; int vcol = wlv.vcol;
StrCharInfo ci = utf_ptr2StrCharInfo(ptr); StrCharInfo ci = utf_ptr2StrCharInfo(ptr);
while (vcol < start_col && *ci.ptr != NUL) { while (vcol < start_col) {
cs = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &csarg); cs = win_charsize(cstype, vcol, ci.ptr, ci.chr.value, &csarg);
vcol += cs.width; vcol += cs.width;
prev_ptr = ci.ptr; prev_ptr = ci.ptr;
if (*prev_ptr == NUL) {
break;
}
ci = utfc_next(ci); ci = utfc_next(ci);
if (wp->w_p_list) { if (wp->w_p_list) {
in_multispace = *prev_ptr == ' ' && (*ci.ptr == ' ' in_multispace = *prev_ptr == ' ' && (*ci.ptr == ' '

View File

@@ -4898,53 +4898,201 @@ describe('decorations: inline virtual text', function()
it('line size is correct with inline virt text at EOL and showbreak', function() it('line size is correct with inline virt text at EOL and showbreak', function()
screen:try_resize(50, 8) screen:try_resize(50, 8)
insert(('0123456789'):rep(5) .. '\nfoo\nbar') insert(('0123456789'):rep(5) .. '\nfoo\nbar')
api.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { ('x'):rep(49), 'ErrorMsg' } }, virt_text_pos = 'inline' }) api.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { ('x'):rep(145), 'ErrorMsg' } }, virt_text_pos = 'inline' })
command([[set showbreak=>\ cursorline]]) command([[set cursorline scrolloff=0 showbreak=>\ smoothscroll]])
screen:expect([[ screen:expect([[
01234567890123456789012345678901234567890123456789| 01234567890123456789012345678901234567890123456789|
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}| {1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3
{1:> }{4:x} |
foo |
{22:ba^r }|
|
]])
eq(5, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all)
feed('<C-E>')
screen:expect([[
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3
{1:> }{4:x} |
foo |
{22:ba^r }|
{1:~ }|
|
]])
feed('<C-E>')
screen:expect([[
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*2
{1:> }{4:x} | {1:> }{4:x} |
foo | foo |
{22:ba^r }| {22:ba^r }|
{1:~ }|*2 {1:~ }|*2
| |
]]) ]])
eq(3, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all) feed('<C-E>')
feed('gg$x<C-O>')
screen:expect([[ screen:expect([[
0123456789012345678901234567890123456789012345678{4:x}|
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}| {1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|
{1:> }{4:x} |
foo | foo |
{22:ba^r }| {22:ba^r }|
{1:~ }|*3 {1:~ }|*3
| |
]]) ]])
eq(2, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all) feed('<C-E>')
screen:expect([[
{1:> }{4:x} |
foo |
{22:ba^r }|
{1:~ }|*4
|
]])
feed('<C-E>')
screen:expect([[
foo |
{22:ba^r }|
{1:~ }|*5
|
]])
feed('gg$xG$')
screen:expect([[
0123456789012345678901234567890123456789012345678{4:x}|
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3
foo |
{22:ba^r }|
{1:~ }|
|
]])
eq(4, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all)
feed('<C-E>')
screen:expect([[
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3
foo |
{22:ba^r }|
{1:~ }|*2
|
]])
feed('<C-E>')
screen:expect([[
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*2
foo |
{22:ba^r }|
{1:~ }|*3
|
]])
feed('<C-E>')
screen:expect([[
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|
foo |
{22:ba^r }|
{1:~ }|*4
|
]])
feed('<C-E>')
screen:expect([[
foo |
{22:ba^r }|
{1:~ }|*5
|
]])
feed('zb')
command('set list listchars=eol:$') command('set list listchars=eol:$')
screen:expect([[ screen:expect([[
0123456789012345678901234567890123456789012345678{4:x}| 0123456789012345678901234567890123456789012345678{4:x}|
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}| {1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3
{1:> $} |
foo{1:$} |
{22:ba^r}{23:$}{22: }|
|
]])
eq(5, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all)
feed('<C-E>')
screen:expect([[
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*3
{1:> $} |
foo{1:$} |
{22:ba^r}{23:$}{22: }|
{1:~ }|
|
]])
feed('<C-E>')
screen:expect([[
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*2
{1:> $} | {1:> $} |
foo{1:$} | foo{1:$} |
{22:ba^r}{23:$}{22: }| {22:ba^r}{23:$}{22: }|
{1:~ }|*2 {1:~ }|*2
| |
]]) ]])
eq(3, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all) feed('<C-E>')
screen:expect([[
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|
{1:> $} |
foo{1:$} |
{22:ba^r}{23:$}{22: }|
{1:~ }|*3
|
]])
feed('<C-E>')
screen:expect([[
{1:> $} |
foo{1:$} |
{22:ba^r}{23:$}{22: }|
{1:~ }|*4
|
]])
feed('<C-E>')
screen:expect([[
foo{1:$} |
{22:ba^r}{23:$}{22: }|
{1:~ }|*5
|
]])
feed('gg$x<C-O>') feed('gg$xG$')
screen:expect([[ screen:expect([[
012345678901234567890123456789012345678901234567{4:xx}| 012345678901234567890123456789012345678901234567{4:xx}|
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*2
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}{1:$}|
foo{1:$} |
{22:ba^r}{23:$}{22: }|
{1:~ }|
|
]])
eq(4, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all)
feed('<C-E>')
screen:expect([[
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|*2
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}{1:$}|
foo{1:$} |
{22:ba^r}{23:$}{22: }|
{1:~ }|*2
|
]])
feed('<C-E>')
screen:expect([[
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}{1:$}| {1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}{1:$}|
foo{1:$} | foo{1:$} |
{22:ba^r}{23:$}{22: }| {22:ba^r}{23:$}{22: }|
{1:~ }|*3 {1:~ }|*3
| |
]]) ]])
eq(2, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all) feed('<C-E>')
screen:expect([[
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}{1:$}|
foo{1:$} |
{22:ba^r}{23:$}{22: }|
{1:~ }|*4
|
]])
feed('<C-E>')
screen:expect([[
foo{1:$} |
{22:ba^r}{23:$}{22: }|
{1:~ }|*5
|
]])
end) end)
end) end)