From 0534ad8ca57bafa76769f49935a6cb00709d155b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 22 Jun 2023 13:41:13 +0800 Subject: [PATCH] fix(extmarks): empty inline virt_text interfering with Visual highlight --- src/nvim/drawline.c | 8 +++----- test/functional/ui/decorations_spec.lua | 8 +++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index b28afb9934..463b4c73ae 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -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; diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 91fbbe2579..0f118b621c 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -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('jf,') screen:expect{grid=[[ for _,item in ipairs(items) do | local text{10:: }{3:string}^, hl_id_cell, count = unpack|