paste: break lines at CR, CRLF #10877

Some terminals helpfully translate \n to \r.

fix #10872
ref #10223
This commit is contained in:
Justin M. Keyes
2019-08-29 23:45:02 +02:00
committed by GitHub
parent 00d46f6328
commit 9f81acc076
6 changed files with 97 additions and 49 deletions

View File

@@ -381,8 +381,7 @@ describe('API', function()
line 2
line 3
]])
-- Cursor follows the paste.
eq({0,4,1,0}, funcs.getpos('.'))
eq({0,4,1,0}, funcs.getpos('.')) -- Cursor follows the paste.
eq(false, nvim('get_option', 'paste'))
command('%delete _')
-- Without final "\n".
@@ -391,8 +390,38 @@ describe('API', function()
line 1
line 2
line 3]])
-- Cursor follows the paste.
eq({0,3,6,0}, funcs.getpos('.'))
command('%delete _')
-- CRLF #10872
nvim('paste', 'line 1\r\nline 2\r\nline 3\r\n', -1)
expect([[
line 1
line 2
line 3
]])
eq({0,4,1,0}, funcs.getpos('.'))
command('%delete _')
-- CRLF without final "\n".
nvim('paste', 'line 1\r\nline 2\r\nline 3\r', -1)
expect([[
line 1
line 2
line 3
]])
eq({0,4,1,0}, funcs.getpos('.'))
command('%delete _')
-- CRLF without final "\r\n".
nvim('paste', 'line 1\r\nline 2\r\nline 3', -1)
expect([[
line 1
line 2
line 3]])
eq({0,3,6,0}, funcs.getpos('.'))
command('%delete _')
-- Various other junk.
nvim('paste', 'line 1\r\n\r\rline 2\nline 3\rline 4\r', -1)
expect('line 1\n\n\nline 2\nline 3\nline 4\n')
eq({0,7,1,0}, funcs.getpos('.'))
eq(false, nvim('get_option', 'paste'))
end)
it('vim.paste() failure', function()