fix(marks): wrong display after inserting/deleting lines #33389

Problem:  Lines to/from which virt_lines or inline virt_text may have
          moved are left valid. Similarly the modified region may be
          too small to account for moved decorations after inserting
          or deleting lines. `redrawOneLine()` can be replaced with
          a call to `changed_lines_redraw_buf()`.

Solution: Invalidate the line after a change if there is virt_lines, or
          inline virt_text in the buffer with 'wrap' enabled. Extend the
          modified region for inserted or deleted lines if there may be
          decorations in the buffer. Remove `redrawOneLine()`.
          Simplify the logic for `changed_lines_invalidate_win()`.

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
(cherry picked from commit 064ff74cdb)
This commit is contained in:
luukvbaal
2025-04-11 13:36:49 +02:00
committed by github-actions[bot]
parent b5158e8e92
commit 9da90af0f7
2 changed files with 96 additions and 28 deletions

View File

@@ -3035,6 +3035,21 @@ describe('extmark decorations', function()
feed('<C-E><C-Y>')
eq(5, n.fn.line('w0'))
end)
it('redraws the line from which a left gravity mark has moved #27369', function()
fn.setline(1, {'aaa', 'bbb', 'ccc', 'ddd' })
api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text = {{'foo'}}, right_gravity = false })
feed('yyp')
screen:expect([[
aaa |
^aaa foo |
bbb |
ccc |
ddd |
{1:~ }|*9
|
]])
end)
end)
describe('decorations: inline virtual text', function()
@@ -4760,6 +4775,67 @@ describe('decorations: inline virtual text', function()
]])
end)
it('is redrawn correctly after delete or redo #27370', function()
screen:try_resize(50, 12)
exec([[
call setline(1, ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff'])
call setline(3, repeat('c', winwidth(0) - 1))
]])
api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text = { { '!!!' } }, virt_text_pos = 'inline' })
feed('j')
local before_delete = [[
aaa |
!!!^bbb |
ccccccccccccccccccccccccccccccccccccccccccccccccc |
ddd |
eee |
fff |
{1:~ }|*5
|
]]
screen:expect(before_delete)
feed('dd')
local after_delete = [[
aaa |
!!!^ccccccccccccccccccccccccccccccccccccccccccccccc|
cc |
ddd |
eee |
fff |
{1:~ }|*5
|
]]
screen:expect(after_delete)
command('silent undo')
screen:expect(before_delete)
command('silent redo')
screen:expect(after_delete)
command('silent undo')
screen:expect(before_delete)
command('set report=100')
feed('yypk2P')
before_delete = [[
aaa |
^bbb |
bbb |
!!!bbb |
bbb |
ccccccccccccccccccccccccccccccccccccccccccccccccc |
ddd |
eee |
fff |
{1:~ }|*2
|
]]
screen:expect(before_delete)
feed('4dd')
screen:expect(after_delete)
command('silent undo')
screen:expect(before_delete)
command('silent redo')
screen:expect(after_delete)
end)
it('cursor position is correct with invalidated inline virt text', function()
screen:try_resize(50, 8)
api.nvim_buf_set_lines(0, 0, -1, false, { ('a'):rep(48), ('b'):rep(48) })