fix(plines): count 'showbreak' in EOL inline virt_text in line size (#35921)

This commit is contained in:
zeertzjq
2025-09-26 12:08:38 +08:00
committed by GitHub
parent 56709ca168
commit 42aae632be
2 changed files with 56 additions and 2 deletions

View File

@@ -456,8 +456,8 @@ int linesize_regular(CharsizeArg *const csarg, int vcol_arg, colnr_T const len)
// Check for inline virtual text after the end of the line.
if (len == MAXCOL && csarg->virt_row >= 0 && *ci.ptr == NUL) {
(void)charsize_regular(csarg, ci.ptr, vcol_arg, ci.chr.value);
vcol += csarg->cur_text_width_left + csarg->cur_text_width_right;
int head = charsize_regular(csarg, ci.ptr, vcol_arg, ci.chr.value).head;
vcol += csarg->cur_text_width_left + csarg->cur_text_width_right + head;
vcol_arg = vcol > MAXCOL ? MAXCOL : (int)vcol;
}

View File

@@ -3590,6 +3590,8 @@ describe('decorations: inline virtual text', function()
[19] = { background = Screen.colors.Yellow, foreground = Screen.colors.SlateBlue },
[20] = { background = Screen.colors.LightGrey, foreground = Screen.colors.SlateBlue },
[21] = { reverse = true, foreground = Screen.colors.SlateBlue },
[22] = { background = Screen.colors.Gray90 },
[23] = { background = Screen.colors.Gray90, foreground = Screen.colors.Blue, bold = true },
}
ns = api.nvim_create_namespace 'test'
@@ -5659,6 +5661,58 @@ describe('decorations: inline virtual text', function()
|
]])
end)
it('line size is correct with inline virt text at EOL and showbreak', function()
screen:try_resize(50, 8)
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' })
command([[set showbreak=>\ cursorline]])
screen:expect([[
01234567890123456789012345678901234567890123456789|
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|
{1:> }{4:x} |
foo |
{22:ba^r }|
{1:~ }|*2
|
]])
eq(3, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all)
feed('gg$x<C-O>')
screen:expect([[
0123456789012345678901234567890123456789012345678{4:x}|
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|
foo |
{22:ba^r }|
{1:~ }|*3
|
]])
eq(2, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all)
command('set list listchars=eol:$')
screen:expect([[
0123456789012345678901234567890123456789012345678{4:x}|
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}|
{1:> $} |
foo{1:$} |
{22:ba^r}{23:$}{22: }|
{1:~ }|*2
|
]])
eq(3, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all)
feed('gg$x<C-O>')
screen:expect([[
012345678901234567890123456789012345678901234567{4:xx}|
{1:> }{4:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}{1:$}|
foo{1:$} |
{22:ba^r}{23:$}{22: }|
{1:~ }|*3
|
]])
eq(2, api.nvim_win_text_height(0, { start_row = 0, end_row = 0 }).all)
end)
end)
describe('decorations: virtual lines', function()