fix(ui): wrong display with 0-width inline virt_text at eol (#24854)

This commit is contained in:
zeertzjq 2023-08-24 11:28:10 +08:00 committed by GitHub
parent e2c10dea19
commit a9418ef8cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -877,7 +877,8 @@ static bool has_more_inline_virt(winlinevars_T *wlv, ptrdiff_t v)
DecorRange *item = &kv_A(state->active, i);
if (item->start_row != state->row
|| !kv_size(item->decor.virt_text)
|| item->decor.virt_text_pos != kVTInline) {
|| item->decor.virt_text_pos != kVTInline
|| item->decor.virt_text_width == 0) {
continue;
}
if (item->draw_col >= -1 && item->start_col >= v) {
@ -899,7 +900,8 @@ static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t
DecorRange *item = &kv_A(state->active, i);
if (item->start_row != state->row
|| !kv_size(item->decor.virt_text)
|| item->decor.virt_text_pos != kVTInline) {
|| item->decor.virt_text_pos != kVTInline
|| item->decor.virt_text_width == 0) {
continue;
}
if (item->draw_col >= -1 && item->start_col == v) {
@ -935,6 +937,7 @@ static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t
// If the text didn't reach until the first window
// column we need to skip cells.
if (wlv->skip_cells > 0) {
// FIXME: this should use virt_text_width instead
int virt_text_len = wlv->n_attr;
if (virt_text_len > wlv->skip_cells) {
int len = mb_charlen2bytelen(wlv->p_extra, wlv->skip_cells);

View File

@ -1748,7 +1748,7 @@ describe('decorations: inline virtual text', function()
]]}
end)
it('works with empty chunk', function()
it('works with 0-width chunk', function()
screen:try_resize(50, 10)
insert(example_text)
feed 'gg'
@ -1766,7 +1766,22 @@ describe('decorations: inline virtual text', function()
]]}
meths.buf_set_extmark(0, ns, 0, 5, {virt_text={{''}, {''}}, virt_text_pos='inline'})
meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'})
meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}}, virt_text_pos='inline'})
meths.buf_set_extmark(0, ns, 1, 48, {virt_text={{''}, {''}}, virt_text_pos='inline'})
screen:expect{grid=[[
^for _,item in ipairs(items) do |
local text{10:: }, hl_id_cell, count = unpack(item)|
if hl_id_cell ~= nil then |
hl_id = hl_id_cell |
end |
for _ = 1, (count or 1) do |
local cell = line[colpos] |
cell.text = text |
cell.hl_id = hl_id |
|
]]}
meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {'string', 'Type'}}, virt_text_pos='inline'})
feed('V')
screen:expect{grid=[[
^f{7:or _,item in ipairs(items) do} |