paste: insert text "before" cursor in Insert-mode

This commit is contained in:
Justin M. Keyes
2019-08-24 14:01:09 +02:00
parent eacc70fb3e
commit bfc5a18f4b
2 changed files with 11 additions and 6 deletions

View File

@@ -101,6 +101,7 @@ local _paste = (function()
return function(lines, phase) return function(lines, phase)
local call = vim.api.nvim_call_function local call = vim.api.nvim_call_function
local now = vim.loop.now() local now = vim.loop.now()
local mode = call('mode', {}):sub(1,1)
if phase == 1 then if phase == 1 then
tdots = now tdots = now
tredraw = now tredraw = now
@@ -110,7 +111,11 @@ local _paste = (function()
-- nvim_cancel() -- nvim_cancel()
-- end -- end
end end
if mode == 'i' or mode == 'R' then
vim.api.nvim_put(lines, 'c', false, true)
else
vim.api.nvim_put(lines, 'c', true, true) vim.api.nvim_put(lines, 'c', true, true)
end
if (now - tredraw >= 1000) or phase == 1 or phase == 3 then if (now - tredraw >= 1000) or phase == 1 or phase == 3 then
tredraw = now tredraw = now
vim.api.nvim_command('redraw') vim.api.nvim_command('redraw')

View File

@@ -156,19 +156,19 @@ describe('TUI', function()
it('paste: Insert mode', function() it('paste: Insert mode', function()
-- "bracketed paste" -- "bracketed paste"
feed_data('i\027[200~') feed_data('i""\027i\027[200~')
screen:expect([[ screen:expect([[
{1: } | "{1:"} |
{4:~ }| {4:~ }|
{4:~ }| {4:~ }|
{4:~ }| {4:~ }|
{5:[No Name] }| {5:[No Name] [+] }|
{3:-- INSERT --} | {3:-- INSERT --} |
{3:-- TERMINAL --} | {3:-- TERMINAL --} |
]]) ]])
feed_data('pasted from terminal') feed_data('pasted from terminal')
screen:expect([[ screen:expect([[
pasted from terminal{1: } | "pasted from terminal{1:"} |
{4:~ }| {4:~ }|
{4:~ }| {4:~ }|
{4:~ }| {4:~ }|
@@ -179,7 +179,7 @@ describe('TUI', function()
feed_data('\027[201~') -- End paste. feed_data('\027[201~') -- End paste.
feed_data('\027\000') -- ESC: go to Normal mode. feed_data('\027\000') -- ESC: go to Normal mode.
screen:expect([[ screen:expect([[
pasted from termina{1:l} | "pasted from termina{1:l}" |
{4:~ }| {4:~ }|
{4:~ }| {4:~ }|
{4:~ }| {4:~ }|