From 46aa254bf30d567bd2da4fbfab33bbdcbb111a37 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 27 Aug 2019 05:19:32 +0200 Subject: paste: handle 'nomodifiable' - nvim_paste(): Marshal through luaeval() instead of nvim_execute_lua() because the latter seems to hide some errors. - Handle 'nomodifiable' in `nvim_put()` explicitly. - Require explicit `false` from `vim.paste()` in order to "cancel", otherwise assume true ("continue"). --- test/functional/terminal/tui_spec.lua | 61 +++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 7 deletions(-) (limited to 'test/functional/terminal/tui_spec.lua') diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index aafbbc04b1..7435b293fd 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -329,14 +329,27 @@ describe('TUI', function() _G.save_paste_fn = vim.paste vim.paste = function(lines, phase) error("fake fail") end ]], {}) + -- Prepare something for dot-repeat/redo. + feed_data('ifoo\n\027\000') + wait_for_mode('n') + screen:expect{grid=[[ + foo | + {1: } | + {4:~ }| + {4:~ }| + {5:[No Name] [+] }| + | + {3:-- TERMINAL --} | + ]]} + wait_for_mode('n') -- Start pasting... feed_data('\027[200~line 1\nline 2\n') screen:expect{grid=[[ + foo | | {4:~ }| - {4:~ }| {5: }| - {8:paste: Error executing lua: [string ""]:2: f}| + {8:paste: Vim:E5108: Error while calling lua chunk fo}| {10:Press ENTER or type command to continue}{1: } | {3:-- TERMINAL --} | ]]} @@ -347,13 +360,24 @@ describe('TUI', function() -- Stop paste. feed_data('\027[201~') feed_data('\n') -- + --Dot-repeat/redo is not modified by failed paste. + feed_data('.') + screen:expect{grid=[[ + foo | + foo | + {1: } | + {4:~ }| + {5:[No Name] [+] }| + | + {3:-- TERMINAL --} | + ]]} -- Editor should still work after failed/drained paste. feed_data('ityped input...\027\000') screen:expect{grid=[[ + foo | + foo | typed input..{1:.} | {4:~ }| - {4:~ }| - {4:~ }| {5:[No Name] [+] }| | {3:-- TERMINAL --} | @@ -365,9 +389,35 @@ describe('TUI', function() feed_data('\027[200~line A\nline B\n\027[201~') feed_data('\n') -- screen:expect{grid=[[ + foo | typed input...line A | line B | {1: } | + {5:[No Name] [+] }| + | + {3:-- TERMINAL --} | + ]]} + end) + + 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{grid=[[ + | + {5: }| + {8:paste: Vim:E5108: Error while calling lua chunk fo}| + {8:r luaeval(): [string "-- Nvim-Lua stdlib: the `vim}| + {8:` module (:help l..."]:193: Buffer is not 'modifia}| + {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~') + screen:expect{grid=[[ + success 1 | + success 2 | + {1: } | {4:~ }| {5:[No Name] [+] }| | @@ -380,9 +430,6 @@ describe('TUI', function() -- Other modes act like CTRL-C + paste. end) - it("paste: in 'nomodifiable' buffer", function() - end) - it('paste: exactly 64 bytes #10311', function() local expected = string.rep('z', 64) feed_data('i') -- cgit