fix(man): don't grow a highlight into the previous line #41490

Problem:
With these two lines (`\b` marking a backspace):

    f\bfoo
    xb\bb

line 1's bold run ends at byte 1 and line 2's begins at byte 1, so line 1
renders "fo" in bold rather than "f", and line 2's "b" is not bold at all.

Solution:
Only grow a highlight group that is on the current row.
This commit is contained in:
Stefan VanBuren
2026-08-26 09:09:17 -04:00
committed by GitHub
parent dad084c394
commit 8d9a798d6d
2 changed files with 5 additions and 4 deletions

View File

@@ -123,8 +123,9 @@ local function render_line(line, row, hls)
attr = Attrs.None
end
-- Grow the previous highlight group if possible
if last_hl and last_hl.attr == attr and last_hl.final == byte then
-- Grow the previous highlight group if possible. `hls` spans the buffer,
-- so only grow a group that is on the current row.
if last_hl and last_hl.row == row and last_hl.attr == attr and last_hl.final == byte then
last_hl.final = byte + #char
else
hls[#hls + 1] = { attr = attr, row = row, start = byte, final = byte + #char }

View File

@@ -183,13 +183,13 @@ describe(':Man', function()
it('highlights various bullet formats', function()
feed(dedent([[
i· ·<C-v><C-h>·
+<C-v><C-h>o
+<C-v><C-h>o
+<C-v><C-h>+<C-v><C-h>o<C-v><C-h>o double<ESC>]]))
exec_lua [[require'man'.init_pager()]]
screen:expect([[
^· {b:·} |
{b:·} |
{b:·} |
{b:·} double |
{eob:~ }|
|