fix(tohtml): properly handle multiple hl groups #29012

Problem: :TOhtml doesn't properly handle virtual text when it has
multiple highlight groups. It also improperly calculates position offset
for multi-byte virt_text characters.

Solution: Apply the `vim.api.nvim_strwidth` broadly to properly
calculate character offset, and handle the cases where the `hl` argument
can be a table of multiple hl groups.
This commit is contained in:
Riley Bruins
2024-05-26 10:27:12 -07:00
committed by GitHub
parent dd54e81551
commit eb37241d38
2 changed files with 16 additions and 6 deletions

View File

@@ -287,7 +287,13 @@ describe(':TOhtml', function()
0,
{ virt_text = { { 'foo' } }, virt_text_pos = 'overlay' }
)
api.nvim_buf_set_extmark(0, ns, 2, 0, { virt_text = { { 'foo' } }, virt_text_pos = 'inline' })
api.nvim_buf_set_extmark(
0,
ns,
2,
0,
{ virt_text = { { 'fo┊o', { 'Conceal', 'Comment' } } }, virt_text_pos = 'inline' }
)
--api.nvim_buf_set_extmark(0,ns,3,0,{virt_text={{'foo'}},virt_text_pos='right_align'})
run_tohtml_and_assert(screen)
end)