mirror of
https://github.com/neovim/neovim.git
synced 2026-09-09 15:35:51 +00:00
fix(multicursor): prevent clipboard crash after cursor jump #41698
Problem: Changing from an empty-line cursor after a multicursor jump can crash while flushing a deferred clipboard update. Exact context restore can leave an omitted register with a null array and stale non-zero size. Solution: Make free_register() fully reset the register after freeing its contents, so it always leaves a valid empty register. Add a regression test. Signed-off-by: sami <samiulsami7786@gmail.com>
This commit is contained in:
@@ -2628,6 +2628,32 @@ describe('multicursor', function()
|
||||
end)
|
||||
|
||||
describe('clipboard', function()
|
||||
it("does not crash after jumping to an empty line with 'clipboard'", function()
|
||||
n.exec_lua([[
|
||||
_G.content = {}
|
||||
vim.g.clipboard = {
|
||||
name = 'test',
|
||||
copy = {
|
||||
['+'] = function(lines)
|
||||
_G.content = lines
|
||||
end,
|
||||
},
|
||||
paste = {
|
||||
['+'] = function()
|
||||
return _G.content
|
||||
end,
|
||||
},
|
||||
}
|
||||
vim.o.clipboard = 'unnamedplus'
|
||||
]])
|
||||
cursors({ '', 'aa' }, 'Qj') -- Cursor on the empty line, primary on the non-empty line.
|
||||
feed(']C') -- Make the empty-line cursor primary.
|
||||
feed('C')
|
||||
n.assert_alive()
|
||||
feed('<Esc>')
|
||||
eq({ '', '' }, get_lines())
|
||||
end)
|
||||
|
||||
it("perf: provider syncs once per cascade with 'clipboard'", function()
|
||||
n.exec_lua([[
|
||||
_G.copies = 0
|
||||
|
||||
Reference in New Issue
Block a user