fix(completion): avoid deleting text when completion leader changes #31448

Problem:  When completion leader changes, text that might be reinserted
          immediately after is deleted. This unnecessarily affects
          extmarks. #31387 restored the original extmarks but that
          prevents end_right_gravity marks from growing.
Solution: Avoid deleting leader text that will be reinserted.
(cherry picked from commit e788d1a3a9)
This commit is contained in:
luukvbaal
2024-12-06 13:07:52 +01:00
committed by github-actions[bot]
parent b5b84b806a
commit 6a63034b51
3 changed files with 44 additions and 13 deletions

View File

@@ -1151,7 +1151,7 @@ describe('completion', function()
command([[
call setline(1, ['aaaa'])
let ns_id = nvim_create_namespace('extmark')
let mark_id = nvim_buf_set_extmark(0, ns_id, 0, 0, { 'end_col':2, 'hl_group':'Error'})
let mark_id = nvim_buf_set_extmark(0, ns_id, 0, 0, { 'end_col':2, 'hl_group':'Error' })
let mark = nvim_buf_get_extmark_by_id(0, ns_id, mark_id, { 'details':1 })
inoremap <C-x> <C-r>=Complete()<CR>
function Complete() abort
@@ -1198,5 +1198,18 @@ describe('completion', function()
{5:-- Keyword completion (^N^P) }{19:Back at original} |
]],
})
-- But still grows with end_right_gravity #31437
command(
"call nvim_buf_set_extmark(0, ns_id, 1, 0, { 'end_col':2, 'hl_group':'Error', 'end_right_gravity': 1 })"
)
feed('<Esc>ji<C-N>a')
screen:expect({
grid = [[
{9:aa}aaa |
{9:aaa}^aa |
aaaaa |
{5:-- INSERT --} |
]],
})
end)
end)