diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2026-04-18 06:33:52 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-18 06:33:52 +0800 |
| commit | 4eaf782bb6cd25408650db497bd4765b7e9782ec (patch) | |
| tree | d0ad15a22607b234d710e60408b72d88f044e2d4 /test/functional/api | |
| parent | e84076c7c6a2d96da46bfebfbf80a20aae41c125 (diff) | |
fix(terminal): forward streamed bracketed paste properly (#39152)
Diffstat (limited to 'test/functional/api')
| -rw-r--r-- | test/functional/api/vim_spec.lua | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 4e9e7b46bf..ecb14ff096 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1228,6 +1228,67 @@ describe('API', function() end) run_streamed_paste_tests() end) + describe('stream: terminal buffer', function() + local eol = is_os('win') and '\r\n' or '\n' + before_each(function() + exec_lua(function() + _G.input = {} + _G.chan = vim.api.nvim_open_term(0, { + on_input = function(_, _, _, data) + if #data > 0 then + table.insert(_G.input, data) + end + end, + force_crlf = false, + }) + end) + end) + local function run_terminal_streamed_paste_tests(check_dot_repeat) + it('without bracketed paste mode in terminal', function() + api.nvim_paste('AA\nBB\n', false, 1) + eq({ 'AA', eol, 'BB', eol }, exec_lua('return _G.input')) + api.nvim_paste('CC', false, 2) + eq({ 'AA', eol, 'BB', eol, 'CC' }, exec_lua('return _G.input')) + api.nvim_paste('\nDD', false, 3) + eq({ 'AA', eol, 'BB', eol, 'CC', eol, 'DD' }, exec_lua('return _G.input')) + if check_dot_repeat then + exec_lua('_G.input = {}') + feed('.') + eq({ 'AA', eol, 'BB', eol, 'CC', eol, 'DD' }, exec_lua('return _G.input')) + end + end) + it('with bracketed paste mode in terminal', function() + exec_lua([[vim.api.nvim_chan_send(_G.chan, '\027[?2004h')]]) + api.nvim_paste('AA\nBB\n', false, 1) + eq({ '\027[200~', 'AA', eol, 'BB', eol }, exec_lua('return _G.input')) + api.nvim_paste('CC', false, 2) + eq({ '\027[200~', 'AA', eol, 'BB', eol, 'CC' }, exec_lua('return _G.input')) + api.nvim_paste('\nDD', false, 3) + eq( + { '\027[200~', 'AA', eol, 'BB', eol, 'CC', eol, 'DD', '\027[201~' }, + exec_lua('return _G.input') + ) + if check_dot_repeat then + exec_lua('_G.input = {}') + feed('.') + eq( + { '\027[200~', 'AA', eol, 'BB', eol, 'CC', eol, 'DD', '\027[201~' }, + exec_lua('return _G.input') + ) + end + end) + end + describe('in Normal mode', function() + run_terminal_streamed_paste_tests(true) + end) + describe('in Terminal mode', function() + before_each(function() + feed('i') + eq({ mode = 't', blocking = false }, api.nvim_get_mode()) + end) + run_terminal_streamed_paste_tests(false) + end) + end) it('non-streaming', function() -- With final "\n". api.nvim_paste('line 1\nline 2\nline 3\n', true, -1) @@ -1947,7 +2008,6 @@ describe('API', function() it('getting current buffer option does not adjust cursor #19381', function() command('new') local buf = api.nvim_get_current_buf() - print(vim.inspect(api.nvim_get_current_buf())) local win = api.nvim_get_current_win() insert('some text') feed('0v$') |
