mirror of
https://github.com/neovim/neovim.git
synced 2026-08-27 17:41:48 +00:00
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:
@@ -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 }
|
||||
|
||||
@@ -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:~ }|
|
||||
|
|
||||
|
||||
Reference in New Issue
Block a user