From 7a857928842476bce8c9bed7cf549fc76c4e6489 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Thu, 29 Aug 2019 12:16:31 +0200 Subject: tui/input: defer nvim_paste properly. Otherwise cursor and redraw code for normal and insert mode will not run. The "tickle" workaround was used for this instead, and can now be removed. The builtin vim.lua got the name [string "-- Nvim-Lua stdlib: thevimmodule (:help l..."] in error messages. Fix it to something reasonable. --- test/functional/terminal/tui_spec.lua | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 8d8c0e3647..07c91d43e1 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -352,15 +352,23 @@ describe('TUI', function() ]]} -- Start pasting... feed_data('\027[200~line 1\nline 2\n') - expect_child_buf_lines({'foo',''}) - screen:expect{any='paste: Error executing lua'} + screen:expect{grid=[[ + foo | + | + {5: }| + {8:paste: Error executing lua: [string ""]:2: f}| + {8:ake fail} | + {10:Press ENTER or type command to continue}{1: } | + {3:-- TERMINAL --} | + ]]} -- Remaining chunks are discarded after vim.paste() failure. feed_data('line 3\nline 4\n') feed_data('line 5\nline 6\n') feed_data('line 7\nline 8\n') -- Stop paste. feed_data('\027[201~') - feed_data('\n') -- + feed_data('\n') -- + expect_child_buf_lines({'foo',''}) --Dot-repeat/redo is not modified by failed paste. feed_data('.') screen:expect{grid=[[ @@ -388,7 +396,7 @@ describe('TUI', function() vim.paste = _G.save_paste_fn ]], {}) feed_data('\027[200~line A\nline B\n\027[201~') - feed_data('\n') -- + feed_data('\n') -- screen:expect{grid=[[ foo | typed input...line A | @@ -414,7 +422,15 @@ describe('TUI', function() it("paste: 'nomodifiable' buffer", function() child_session:request('nvim_command', 'set nomodifiable') feed_data('\027[200~fail 1\nfail 2\n\027[201~') - screen:expect{any='Vim:E21'} + screen:expect{grid=[[ + | + {4:~ }| + {5: }| + {8:paste: Error executing lua: vim.lua:194: Vim:E21: }| + {8:Cannot make changes, 'modifiable' is off} | + {10:Press ENTER or type command to continue}{1: } | + {3:-- TERMINAL --} | + ]]} feed_data('\n') -- child_session:request('nvim_command', 'set modifiable') feed_data('\027[200~success 1\nsuccess 2\n\027[201~') -- cgit From dff06a90e496c93931b4761ee9538a301477690f Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Fri, 30 Aug 2019 20:19:56 +0200 Subject: api: make nvim_put support "\022{NUM}" regtype as returned by getregtype() --- test/functional/api/vim_spec.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 6f7661dd76..02e83c4d58 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -518,6 +518,35 @@ describe('API', function() line 3]]) eq({0,3,6,0}, funcs.getpos('.')) end) + + it('allows block width', function() + -- behave consistently with setreg(); support "\022{NUM}" return by getregtype() + meths.put({'line 1','line 2','line 3'}, 'l', false, false) + expect([[ + line 1 + line 2 + line 3 + ]]) + + -- larger width create spaces + meths.put({'a', 'bc'}, 'b3', false, false) + expect([[ + a line 1 + bc line 2 + line 3 + ]]) + -- smaller width is ignored + meths.put({'xxx', 'yyy'}, '\0221', false, true) + expect([[ + xxxa line 1 + yyybc line 2 + line 3 + ]]) + eq({false, "Invalid type: 'bx'"}, + meth_pcall(meths.put, {'xxx', 'yyy'}, 'bx', false, true)) + eq({false, "Invalid type: 'b3x'"}, + meth_pcall(meths.put, {'xxx', 'yyy'}, 'b3x', false, true)) + end) end) describe('nvim_strwidth', function() -- cgit