mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(ui): wrong display with 0-width inline virt_text at eol (#24854)
This commit is contained in:
@@ -877,7 +877,8 @@ static bool has_more_inline_virt(winlinevars_T *wlv, ptrdiff_t v)
|
|||||||
DecorRange *item = &kv_A(state->active, i);
|
DecorRange *item = &kv_A(state->active, i);
|
||||||
if (item->start_row != state->row
|
if (item->start_row != state->row
|
||||||
|| !kv_size(item->decor.virt_text)
|
|| !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;
|
continue;
|
||||||
}
|
}
|
||||||
if (item->draw_col >= -1 && item->start_col >= v) {
|
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);
|
DecorRange *item = &kv_A(state->active, i);
|
||||||
if (item->start_row != state->row
|
if (item->start_row != state->row
|
||||||
|| !kv_size(item->decor.virt_text)
|
|| !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;
|
continue;
|
||||||
}
|
}
|
||||||
if (item->draw_col >= -1 && item->start_col == v) {
|
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
|
// If the text didn't reach until the first window
|
||||||
// column we need to skip cells.
|
// column we need to skip cells.
|
||||||
if (wlv->skip_cells > 0) {
|
if (wlv->skip_cells > 0) {
|
||||||
|
// FIXME: this should use virt_text_width instead
|
||||||
int virt_text_len = wlv->n_attr;
|
int virt_text_len = wlv->n_attr;
|
||||||
if (virt_text_len > wlv->skip_cells) {
|
if (virt_text_len > wlv->skip_cells) {
|
||||||
int len = mb_charlen2bytelen(wlv->p_extra, wlv->skip_cells);
|
int len = mb_charlen2bytelen(wlv->p_extra, wlv->skip_cells);
|
||||||
|
@@ -1748,7 +1748,7 @@ describe('decorations: inline virtual text', function()
|
|||||||
]]}
|
]]}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works with empty chunk', function()
|
it('works with 0-width chunk', function()
|
||||||
screen:try_resize(50, 10)
|
screen:try_resize(50, 10)
|
||||||
insert(example_text)
|
insert(example_text)
|
||||||
feed 'gg'
|
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, 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')
|
feed('V')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
^f{7:or _,item in ipairs(items) do} |
|
^f{7:or _,item in ipairs(items) do} |
|
||||||
|
Reference in New Issue
Block a user