Merge #10975 'paste: fix various bugs'

This commit is contained in:
Justin M. Keyes
2019-09-08 18:40:46 -07:00
committed by GitHub
3 changed files with 16 additions and 12 deletions

View File

@@ -239,7 +239,7 @@ GUIs can paste by calling |nvim_paste()|.
PASTE BEHAVIOR ~
Paste inserts text after the cursor. Lines break at <NL>, <CR>, and <CR><NL>.
Paste inserts text before the cursor. Lines break at <NL>, <CR> and <CR><NL>.
When pasting a huge amount of text, screen-updates are throttled and the
message area shows a "..." pulse.

View File

@@ -191,10 +191,8 @@ paste = (function()
local line1, _ = string.gsub(lines[1], '[\r\n\012\027]', ' ') -- Scrub.
vim.api.nvim_input(line1)
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)
else
vim.api.nvim_put(lines, 'c', true, true)
end
if phase ~= -1 and (now - tdots >= 100) then
local dots = ('.'):rep(tick % 4)
@@ -205,8 +203,7 @@ paste = (function()
vim.api.nvim_command(('echo "%s"'):format(dots))
end
if phase == -1 or phase == 3 then
vim.api.nvim_command('redraw')
vim.api.nvim_command('echo ""')
vim.api.nvim_command('redraw'..(tick > 1 and '|echo ""' or ''))
end
return true -- Paste will not continue if not returning `true`.
end

View File

@@ -319,7 +319,7 @@ describe('TUI', function()
{1:x} |
{4:~ }|
{5:[No Name] [+] 3,1 All}|
|
:set ruler |
{3:-- TERMINAL --} |
]]
local expected_attr = {
@@ -353,7 +353,11 @@ describe('TUI', function()
expect_child_buf_lines({''})
-- CRLF input
feed_data('\027[200~'..table.concat(expected_lf,'\r\n')..'\027[201~')
screen:expect{grid=expected_grid1, attr_ids=expected_attr}
screen:expect{
grid=expected_grid1:gsub(
':set ruler *',
'3 fewer lines; before #1 0 seconds ago '),
attr_ids=expected_attr}
expect_child_buf_lines(expected_crlf)
end)
@@ -363,7 +367,10 @@ describe('TUI', function()
feed_data('\027[D') -- <Left> to place cursor between quotes.
wait_for_mode('c')
-- "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=[[
foo |
|
@@ -478,9 +485,9 @@ describe('TUI', function()
feed_data('\n') -- <CR>
screen:expect{grid=[[
foo |
typed input...line A |
typed input..line A |
line B |
{1: } |
{1:.} |
{5:[No Name] [+] }|
|
{3:-- TERMINAL --} |
@@ -505,7 +512,7 @@ describe('TUI', function()
|
{4:~ }|
{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} |
{10:Press ENTER or type command to continue}{1: } |
{3:-- TERMINAL --} |