From 8d9a798d6d99c60d9434584d0d5dc38f3f57b2bd Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Wed, 26 Aug 2026 09:09:17 -0400 Subject: [PATCH] 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. --- runtime/lua/man.lua | 5 +++-- test/functional/plugin/man_spec.lua | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua index 2fa054a855..18f27ba984 100644 --- a/runtime/lua/man.lua +++ b/runtime/lua/man.lua @@ -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 } diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua index 17d9e6cd6f..0217543461 100644 --- a/test/functional/plugin/man_spec.lua +++ b/test/functional/plugin/man_spec.lua @@ -183,13 +183,13 @@ describe(':Man', function() it('highlights various bullet formats', function() feed(dedent([[ i· ·· - +o + +o ++oo double]])) exec_lua [[require'man'.init_pager()]] screen:expect([[ ^· {b:·} | - {b:·} | + {b:·} | {b:·} double | {eob:~ }| |