+61
-17
lines changedFilter options
+61
-17
lines changed Original file line number Diff line number Diff line change
@@ -171,27 +171,34 @@ do
171
171
vim.api.nvim_input(line1)
172
172
vim.api.nvim_set_option('paste', false)
173
173
elseif not is_cmdline then
174
-
if phase < 2 and mode:find('^[vV\22sS\19]') then
175
-
vim.api.nvim_command([[exe "normal! \<Del>"]])
174
+
if mode:find('^i') or mode:find('^n?t') then -- Insert mode or Terminal buffer
176
175
vim.api.nvim_put(lines, 'c', false, true)
177
-
elseif phase < 2 and not mode:find('^[iRt]') then
178
-
vim.api.nvim_put(lines, 'c', true, true)
179
-
-- XXX: Normal-mode: workaround bad cursor-placement after first chunk.
180
-
vim.api.nvim_command('normal! a')
181
-
elseif phase < 2 and mode:find('^R') then
176
+
elseif phase < 2 and mode:find('^R') and not mode:find('^Rv') then -- Replace mode
177
+
-- TODO: implement Replace mode streamed pasting
178
+
-- TODO: support Virtual Replace mode
182
179
local nchars = 0
183
180
for _, line in ipairs(lines) do
184
-
nchars = nchars + line:len()
181
+
nchars = nchars + line:len()
185
182
end
186
183
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
187
184
local bufline = vim.api.nvim_buf_get_lines(0, row-1, row, true)[1]
188
185
local firstline = lines[1]
189
186
firstline = bufline:sub(1, col)..firstline
190
187
lines[1] = firstline
188
+
-- FIXME: #lines can be 0
191
189
lines[#lines] = lines[#lines]..bufline:sub(col + nchars + 1, bufline:len())
192
190
vim.api.nvim_buf_set_lines(0, row-1, row, false, lines)
193
-
else
194
-
vim.api.nvim_put(lines, 'c', false, true)
191
+
elseif mode:find('^[nvV\22sS\19]') then -- Normal or Visual or Select mode
192
+
if mode:find('^n') then -- Normal mode
193
+
vim.api.nvim_put(lines, 'c', true, false)
194
+
else -- Visual or Select mode
195
+
vim.api.nvim_command([[exe "normal! \<Del>"]])
196
+
vim.api.nvim_put(lines, 'c', false, false)
197
+
end
198
+
-- put cursor at the end of the text instead of one character after it
199
+
vim.fn.setpos('.', vim.fn.getpos("']"))
200
+
else -- Don't know what to do in other modes
201
+
return false
195
202
end
196
203
end
197
204
if phase ~= -1 and (now - tdots >= 100) then
Original file line number Diff line number Diff line change
@@ -665,6 +665,43 @@ describe('API', function()
665
665
feed('u') -- Undo.
666
666
expect(expected1)
667
667
end)
668
+
it('stream: Insert mode', function()
669
+
feed('i')
670
+
nvim('paste', 'aaaaaa', false, 1)
671
+
nvim('paste', 'bbbbbb', false, 2)
672
+
nvim('paste', 'cccccc', false, 2)
673
+
nvim('paste', 'dddddd', false, 3)
674
+
expect('aaaaaabbbbbbccccccdddddd')
675
+
end)
676
+
it('stream: Normal mode on empty line', function()
677
+
nvim('paste', 'aaaaaa', false, 1)
678
+
nvim('paste', 'bbbbbb', false, 2)
679
+
nvim('paste', 'cccccc', false, 2)
680
+
nvim('paste', 'dddddd', false, 3)
681
+
expect('aaaaaabbbbbbccccccdddddd')
682
+
feed('u')
683
+
expect('')
684
+
end)
685
+
it('stream: Normal mode not at the end of a line', function()
686
+
feed('i||<Esc>0')
687
+
nvim('paste', 'aaaaaa', false, 1)
688
+
nvim('paste', 'bbbbbb', false, 2)
689
+
nvim('paste', 'cccccc', false, 2)
690
+
nvim('paste', 'dddddd', false, 3)
691
+
expect('|aaaaaabbbbbbccccccdddddd|')
692
+
feed('u')
693
+
expect('||')
694
+
end)
695
+
it('stream: Normal mode at the end of a line', function()
696
+
feed('i||<Esc>')
697
+
nvim('paste', 'aaaaaa', false, 1)
698
+
nvim('paste', 'bbbbbb', false, 2)
699
+
nvim('paste', 'cccccc', false, 2)
700
+
nvim('paste', 'dddddd', false, 3)
701
+
expect('||aaaaaabbbbbbccccccdddddd')
702
+
feed('u')
703
+
expect('||')
704
+
end)
668
705
it('non-streaming', function()
669
706
-- With final "\n".
670
707
nvim('paste', 'line 1\nline 2\nline 3\n', true, -1)
Original file line number Diff line number Diff line change
@@ -323,7 +323,7 @@ describe('TUI', function()
323
323
feed_data('just paste it™')
324
324
feed_data('\027[201~')
325
325
screen:expect{grid=[[
326
-
thisjust paste it™{1:3} is here |
326
+
thisjust paste it{1:™}3 is here |
327
327
|
328
328
{4:~ }|
329
329
{4:~ }|
@@ -379,7 +379,7 @@ describe('TUI', function()
379
379
end)
380
380
381
381
it('paste: normal-mode (+CRLF #10872)', function()
382
-
feed_data(':set ruler')
382
+
feed_data(':set ruler | echo')
383
383
wait_for_mode('c')
384
384
feed_data('\n')
385
385
wait_for_mode('n')
@@ -423,13 +423,13 @@ describe('TUI', function()
423
423
expect_child_buf_lines(expected_crlf)
424
424
feed_data('u')
425
425
expect_child_buf_lines({''})
426
+
feed_data(':echo')
427
+
wait_for_mode('c')
428
+
feed_data('\n')
429
+
wait_for_mode('n')
426
430
-- CRLF input
427
431
feed_data('\027[200~'..table.concat(expected_lf,'\r\n')..'\027[201~')
428
-
screen:expect{
429
-
grid=expected_grid1:gsub(
430
-
':set ruler *',
431
-
'3 fewer lines; before #1 0 seconds ago '),
432
-
attr_ids=expected_attr}
432
+
screen:expect{grid=expected_grid1, attr_ids=expected_attr}
433
433
expect_child_buf_lines(expected_crlf)
434
434
end)
435
435
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4