mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
fix(buffer_updates): save and restore current window cursor (#16732)
When a buffer update callback is called, textlock is active so buffer text cannot be changed, but cursor can still be moved. This can cause problems when the buffer update is in the middle of an operator, like the one mentioned in #16729. The solution is to save cursor position and restore it afterwards, like how cursor is saved and restored when evaluating an <expr> mapping.
This commit is contained in:
@@ -317,7 +317,18 @@ describe('lua buffer event callbacks: on_lines', function()
|
||||
feed('1G0')
|
||||
feed('P')
|
||||
eq(meths.get_var('linesev'), { "lines", 1, 6, 0, 3, 3, 9 })
|
||||
end)
|
||||
|
||||
it('calling nvim_buf_call() from callback does not cause Normal mode CTRL-A to misbehave #16729', function()
|
||||
exec_lua([[
|
||||
vim.api.nvim_buf_attach(0, false, {
|
||||
on_lines = function(...)
|
||||
vim.api.nvim_buf_call(0, function() end)
|
||||
end,
|
||||
})
|
||||
]])
|
||||
feed('itest123<Esc><C-A>')
|
||||
eq('test124', meths.get_current_line())
|
||||
end)
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user