fix(extmarks): fix virt_text_hide off-by-one hiding (#23795)

This commit is contained in:
zeertzjq 2023-05-28 17:29:44 +08:00 committed by GitHub
parent 4dd43e31db
commit 9c41a81dec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -1728,7 +1728,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int mod_top, bo
wlv.draw_state = WL_LINE;
if (has_decor && wlv.row == startrow + wlv.filler_lines) {
// hide virt_text on text hidden by 'nowrap' or 'smoothscroll'
decor_redraw_col(wp, (colnr_T)(ptr - line), wlv.off, true, &decor_state);
decor_redraw_col(wp, (colnr_T)(ptr - line) - 1, wlv.off, true, &decor_state);
}
win_line_continue(&wlv); // use wlv.saved_ values
}

View File

@ -837,9 +837,10 @@ describe('extmark decorations', function()
screen:try_resize(50, 3)
command('set nowrap')
meths.buf_set_lines(0, 0, -1, true, {'-- ' .. (''):rep(57)})
meths.buf_set_extmark(0, ns, 0, 0, { virt_text={{'?????', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true})
meths.buf_set_extmark(0, ns, 0, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true})
screen:expect{grid=[[
^-- {4:!!!!!}|
{4:^?????}{4:!!!!!}|
{1:~ }|
|
]]}
@ -849,7 +850,13 @@ describe('extmark decorations', function()
{1:~ }|
|
]]}
feed('10zl')
feed('3zl')
screen:expect{grid=[[
{4:^!!!!!} |
{1:~ }|
|
]]}
feed('7zl')
screen:expect{grid=[[
^ |
{1:~ }|
@ -858,7 +865,7 @@ describe('extmark decorations', function()
command('set wrap smoothscroll')
screen:expect{grid=[[
-- …………………………………………………………………………………………………………{4:!!!!!}……|
{4:?????}{4:!!!!!}|
^ |
|
]]}
@ -876,7 +883,7 @@ describe('extmark decorations', function()
]]}
feed('<C-Y>')
screen:expect{grid=[[
-- …………………………………………………………………………………………………|
{4:?????}|
{4:!!!!!}^ |
|
]]}