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:~ }| |