diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua index 637a4baf33..59438c8667 100644 --- a/src/nvim/lua/vim.lua +++ b/src/nvim/lua/vim.lua @@ -101,6 +101,7 @@ local _paste = (function() return function(lines, phase) local call = vim.api.nvim_call_function local now = vim.loop.now() + local mode = call('mode', {}):sub(1,1) if phase == 1 then tdots = now tredraw = now @@ -110,7 +111,11 @@ local _paste = (function() -- nvim_cancel() -- end end - vim.api.nvim_put(lines, 'c', true, true) + if mode == 'i' or mode == 'R' then + vim.api.nvim_put(lines, 'c', false, true) + else + vim.api.nvim_put(lines, 'c', true, true) + end if (now - tredraw >= 1000) or phase == 1 or phase == 3 then tredraw = now vim.api.nvim_command('redraw') diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 414838444f..e6d9dcddb9 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -156,19 +156,19 @@ describe('TUI', function() it('paste: Insert mode', function() -- "bracketed paste" - feed_data('i\027[200~') + feed_data('i""\027i\027[200~') screen:expect([[ - {1: } | + "{1:"} | {4:~ }| {4:~ }| {4:~ }| - {5:[No Name] }| + {5:[No Name] [+] }| {3:-- INSERT --} | {3:-- TERMINAL --} | ]]) feed_data('pasted from terminal') screen:expect([[ - pasted from terminal{1: } | + "pasted from terminal{1:"} | {4:~ }| {4:~ }| {4:~ }| @@ -179,7 +179,7 @@ describe('TUI', function() feed_data('\027[201~') -- End paste. feed_data('\027\000') -- ESC: go to Normal mode. screen:expect([[ - pasted from termina{1:l} | + "pasted from termina{1:l}" | {4:~ }| {4:~ }| {4:~ }|