mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 20:08:17 +00:00
fix(extmarks): empty inline virt_text interfering with DiffText (#24101)
This commit is contained in:
@@ -897,14 +897,16 @@ static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t
|
|||||||
} else {
|
} else {
|
||||||
// already inside existing inline virtual text with multiple chunks
|
// already inside existing inline virtual text with multiple chunks
|
||||||
VirtTextChunk vtc = kv_A(wlv->virt_inline, wlv->virt_inline_i);
|
VirtTextChunk vtc = kv_A(wlv->virt_inline, wlv->virt_inline_i);
|
||||||
|
wlv->virt_inline_i++;
|
||||||
wlv->p_extra = vtc.text;
|
wlv->p_extra = vtc.text;
|
||||||
wlv->n_extra = (int)strlen(wlv->p_extra);
|
wlv->n_extra = (int)strlen(vtc.text);
|
||||||
wlv->extra_for_extmark = true;
|
if (wlv->n_extra == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
wlv->c_extra = NUL;
|
wlv->c_extra = NUL;
|
||||||
wlv->c_final = NUL;
|
wlv->c_final = NUL;
|
||||||
wlv->extra_attr = vtc.hl_id ? syn_id2attr(vtc.hl_id) : 0;
|
wlv->extra_attr = vtc.hl_id ? syn_id2attr(vtc.hl_id) : 0;
|
||||||
wlv->n_attr = mb_charlen(vtc.text);
|
wlv->n_attr = mb_charlen(vtc.text);
|
||||||
wlv->virt_inline_i++;
|
|
||||||
// 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) {
|
||||||
@@ -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->skipped_cells += virt_text_len;
|
||||||
wlv->n_attr = 0;
|
wlv->n_attr = 0;
|
||||||
wlv->n_extra = 0;
|
wlv->n_extra = 0;
|
||||||
|
|
||||||
// go to the start so the next virtual text chunk can be selected.
|
// go to the start so the next virtual text chunk can be selected.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert(wlv->n_extra > 0);
|
||||||
|
wlv->extra_for_extmark = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2216,6 +2216,51 @@ bbbbbbb]])
|
|||||||
]]}
|
]]}
|
||||||
end)
|
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()
|
it('highlighting is correct when virtual text wraps with number', function()
|
||||||
insert([[
|
insert([[
|
||||||
test
|
test
|
||||||
@@ -2279,9 +2324,11 @@ bbbbbbb]])
|
|||||||
9000
|
9000
|
||||||
0009
|
0009
|
||||||
]])
|
]])
|
||||||
|
insert('aaa\tbbb')
|
||||||
command("set diff")
|
command("set diff")
|
||||||
meths.buf_set_extmark(0, ns, 0, 1,
|
meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false })
|
||||||
{ 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")
|
command("vnew")
|
||||||
insert([[
|
insert([[
|
||||||
000
|
000
|
||||||
@@ -2290,6 +2337,7 @@ bbbbbbb]])
|
|||||||
000
|
000
|
||||||
000
|
000
|
||||||
]])
|
]])
|
||||||
|
insert('aaabbb')
|
||||||
command("set diff")
|
command("set diff")
|
||||||
feed('gg0')
|
feed('gg0')
|
||||||
screen:expect { grid = [[
|
screen:expect { grid = [[
|
||||||
@@ -2298,12 +2346,26 @@ bbbbbbb]])
|
|||||||
{9:000 }│{9:000}{5:9}{9: }|
|
{9:000 }│{9:000}{5:9}{9: }|
|
||||||
{9:000 }│{5:9}{9:000 }|
|
{9:000 }│{5:9}{9:000 }|
|
||||||
{9:000 }│{9:000}{5:9}{9: }|
|
{9:000 }│{9:000}{5:9}{9: }|
|
||||||
│ |
|
{9:aaabbb }│{14:!}{9:aaa}{5: }{9:bbb }|
|
||||||
{1:~ }│{1:~ }|
|
{1:~ }│{1:~ }|
|
||||||
{1:~ }│{1:~ }|
|
{1:~ }│{1:~ }|
|
||||||
{15:[No Name] [+] }{13:[No Name] [+] }|
|
{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)
|
end)
|
||||||
|
|
||||||
it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function()
|
it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function()
|
||||||
|
Reference in New Issue
Block a user