paste/cmdline: discard all chunks after first line

Problem:  If multiple paste "chunks" are streamed, chunks after the
          first line are pasted into the buffer.
Solution: Check for cmdline-mode for all chunks in a paste-stream.
This commit is contained in:
Justin M. Keyes
2019-09-08 13:48:46 -07:00
parent ccd947ca4a
commit 0dea44f93c
2 changed files with 7 additions and 6 deletions

View File

@@ -191,10 +191,8 @@ paste = (function()
local line1, _ = string.gsub(lines[1], '[\r\n\012\027]', ' ') -- Scrub. local line1, _ = string.gsub(lines[1], '[\r\n\012\027]', ' ') -- Scrub.
vim.api.nvim_input(line1) vim.api.nvim_input(line1)
vim.api.nvim_set_option('paste', false) vim.api.nvim_set_option('paste', false)
elseif mode == 'i' or mode == 'R' then elseif mode ~= 'c' then
vim.api.nvim_put(lines, 'c', false, true) vim.api.nvim_put(lines, 'c', (mode ~= 'i' and mode ~= 'R'), true)
else
vim.api.nvim_put(lines, 'c', true, true)
end end
if phase ~= -1 and (now - tdots >= 100) then if phase ~= -1 and (now - tdots >= 100) then
local dots = ('.'):rep(tick % 4) local dots = ('.'):rep(tick % 4)

View File

@@ -363,7 +363,10 @@ describe('TUI', function()
feed_data('\027[D') -- <Left> to place cursor between quotes. feed_data('\027[D') -- <Left> to place cursor between quotes.
wait_for_mode('c') wait_for_mode('c')
-- "bracketed paste" -- "bracketed paste"
feed_data('\027[200~line 1\nline 2\n\027[201~') feed_data('\027[200~line 1\nline 2\n')
wait_for_mode('c')
feed_data('line 3\nline 4\n\027[201~')
wait_for_mode('c')
screen:expect{grid=[[ screen:expect{grid=[[
foo | foo |
| |
@@ -505,7 +508,7 @@ describe('TUI', function()
| |
{4:~ }| {4:~ }|
{5: }| {5: }|
{8:paste: Error executing lua: vim.lua:197: Vim:E21: }| {8:paste: Error executing lua: vim.lua:195: Vim:E21: }|
{8:Cannot make changes, 'modifiable' is off} | {8:Cannot make changes, 'modifiable' is off} |
{10:Press ENTER or type command to continue}{1: } | {10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} | {3:-- TERMINAL --} |