From 6bb1aa74e6fe26bffbbdb91878f8f07477c01fcc Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 9 Jul 2026 19:50:16 +0200 Subject: refactor: unify context-switching concepts --- test/functional/api/buffer_spec.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/functional/api/buffer_spec.lua') diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index a81c1ed1c7..1ed77c41ff 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -2553,6 +2553,16 @@ describe('api/buf', function() end) describe('nvim_buf_call', function() + it('preserves visual-mode, unless the callback ended it', function() + -- Same-buffer: Visual survives untouched. + command('normal! v') + exec_lua('vim.api.nvim_buf_call(0, function() end)') + eq('v', fn.mode()) + -- The callback ends Visual mode: it must STAY ended. + exec_lua([[vim.api.nvim_buf_call(0, function() vim.cmd('normal! \27') end)]]) + eq('n', fn.mode()) + end) + it('supports multiple returns', function() local curbuf = api.nvim_get_current_buf() local other = api.nvim_create_buf(false, true) -- cgit