aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/drawline.c11
-rw-r--r--test/functional/ui/decorations_spec.lua68
2 files changed, 72 insertions, 7 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 463b4c73ae..55f0d69aaf 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -897,14 +897,16 @@ static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t
} else {
// already inside existing inline virtual text with multiple chunks
VirtTextChunk vtc = kv_A(wlv->virt_inline, wlv->virt_inline_i);
+ wlv->virt_inline_i++;
wlv->p_extra = vtc.text;
- wlv->n_extra = (int)strlen(wlv->p_extra);
- wlv->extra_for_extmark = true;
+ wlv->n_extra = (int)strlen(vtc.text);
+ if (wlv->n_extra == 0) {
+ continue;
+ }
wlv->c_extra = NUL;
wlv->c_final = NUL;
wlv->extra_attr = vtc.hl_id ? syn_id2attr(vtc.hl_id) : 0;
wlv->n_attr = mb_charlen(vtc.text);
- wlv->virt_inline_i++;
// If the text didn't reach until the first window
// column we need to skip cells.
if (wlv->skip_cells > 0) {
@@ -925,11 +927,12 @@ static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t
wlv->skipped_cells += virt_text_len;
wlv->n_attr = 0;
wlv->n_extra = 0;
-
// go to the start so the next virtual text chunk can be selected.
continue;
}
}
+ assert(wlv->n_extra > 0);
+ wlv->extra_for_extmark = true;
}
}
}
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 0f118b621c..6772ef036a 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -2216,6 +2216,51 @@ bbbbbbb]])
]]}
end)
+ it('hidden virtual text does not interfere with Visual highlight', function()
+ insert('abcdef')
+ command('set nowrap')
+ meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'XXX', 'Special' } }, virt_text_pos = 'inline' })
+ feed('V2zl')
+ screen:expect{grid=[[
+ {10:X}{7:abcde}^f |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {8:-- VISUAL LINE --} |
+ ]]}
+ feed('zl')
+ screen:expect{grid=[[
+ {7:abcde}^f |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {8:-- VISUAL LINE --} |
+ ]]}
+ feed('zl')
+ screen:expect{grid=[[
+ {7:bcde}^f |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {8:-- VISUAL LINE --} |
+ ]]}
+ end)
+
it('highlighting is correct when virtual text wraps with number', function()
insert([[
test
@@ -2279,9 +2324,11 @@ bbbbbbb]])
9000
0009
]])
+ insert('aaa\tbbb')
command("set diff")
- meths.buf_set_extmark(0, ns, 0, 1,
- { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false })
+ meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false })
+ meths.buf_set_extmark(0, ns, 5, 0, { virt_text = { { '!', 'Special' } }, virt_text_pos = 'inline' })
+ meths.buf_set_extmark(0, ns, 5, 3, { virt_text = { { '' } }, virt_text_pos = 'inline' })
command("vnew")
insert([[
000
@@ -2290,6 +2337,7 @@ bbbbbbb]])
000
000
]])
+ insert('aaabbb')
command("set diff")
feed('gg0')
screen:expect { grid = [[
@@ -2298,12 +2346,26 @@ bbbbbbb]])
{9:000 }│{9:000}{5:9}{9: }|
{9:000 }│{5:9}{9:000 }|
{9:000 }│{9:000}{5:9}{9: }|
- │ |
+ {9:aaabbb }│{14:!}{9:aaa}{5: }{9:bbb }|
{1:~ }│{1:~ }|
{1:~ }│{1:~ }|
{15:[No Name] [+] }{13:[No Name] [+] }|
|
]]}
+ command('wincmd w | set nowrap')
+ feed('zl')
+ screen:expect { grid = [[
+ {9:000 }│{14:test}{9:000 }|
+ {9:000 }│{9:00}{5:9}{9: }|
+ {9:000 }│{9:00}{5:9}{9: }|
+ {9:000 }│{9:000 }|
+ {9:000 }│{9:00}{5:9}{9: }|
+ {9:aaabbb }│{9:aaa}{5: }{9:bb^b }|
+ {1:~ }│{1:~ }|
+ {1:~ }│{1:~ }|
+ {13:[No Name] [+] }{15:[No Name] [+] }|
+ |
+ ]]}
end)
it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function()