fix(extmarks): empty inline virt_text interfering with Visual highlight

This commit is contained in:
zeertzjq 2023-06-22 13:41:13 +08:00
parent 08db61b19b
commit 0534ad8ca5
2 changed files with 8 additions and 8 deletions

View File

@ -869,7 +869,7 @@ static void apply_cursorline_highlight(win_T *wp, winlinevars_T *wlv)
}
}
static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t v, bool *do_save)
static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t v)
{
while (wlv->n_extra == 0) {
if (wlv->virt_inline_i >= kv_size(wlv->virt_inline)) {
@ -905,7 +905,6 @@ static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t
wlv->extra_attr = vtc.hl_id ? syn_id2attr(vtc.hl_id) : 0;
wlv->n_attr = mb_charlen(vtc.text);
wlv->virt_inline_i++;
*do_save = true;
// If the text didn't reach until the first window
// column we need to skip cells.
if (wlv->skip_cells > 0) {
@ -1795,9 +1794,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
extmark_attr = decor_redraw_col(wp, (colnr_T)v, wlv.off, selected, &decor_state);
if (!has_fold) {
bool do_save = false;
handle_inline_virtual_text(wp, &wlv, v, &do_save);
if (do_save) {
handle_inline_virtual_text(wp, &wlv, v);
if (wlv.n_extra > 0) {
// restore search_attr and area_attr when n_extra is down to zero
// TODO(bfredl): this is ugly as fuck. look if we can do this some other way.
saved_search_attr = search_attr;

View File

@ -1675,9 +1675,11 @@ 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'})
feed('V')
screen:expect{grid=[[
^for _,item in ipairs(items) do |
^f{7:or _,item in ipairs(items) do} |
local text{10:: }{3:string}, hl_id_cell, count = unpack|
(item) |
if hl_id_cell ~= nil then |
@ -1686,10 +1688,10 @@ describe('decorations: inline virtual text', function()
for _ = 1, (count or 1) do |
local cell = line[colpos] |
cell.text = text |
|
{8:-- VISUAL LINE --} |
]]}
feed('jf,')
feed('<Esc>jf,')
screen:expect{grid=[[
for _,item in ipairs(items) do |
local text{10:: }{3:string}^, hl_id_cell, count = unpack|