diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-03-09 10:19:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-09 10:19:00 +0800 |
commit | 89a525de9f2551e460cc91d40fd7afbb7e07622f (patch) | |
tree | 2e9bd543d89b693c7a6382fa66ec82488f8a0c61 /test/functional/lua/buffer_updates_spec.lua | |
parent | eaccd0decd707ff7cec318e06914f963daa9574c (diff) | |
download | rneovim-89a525de9f2551e460cc91d40fd7afbb7e07622f.tar.gz rneovim-89a525de9f2551e460cc91d40fd7afbb7e07622f.tar.bz2 rneovim-89a525de9f2551e460cc91d40fd7afbb7e07622f.zip |
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.
Diffstat (limited to 'test/functional/lua/buffer_updates_spec.lua')
-rw-r--r-- | test/functional/lua/buffer_updates_spec.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index 2fd44b8b5f..b1b39501f7 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -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) |