aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/lua/vim/_editor.lua3
-rw-r--r--test/functional/api/vim_spec.lua8
2 files changed, 10 insertions, 1 deletions
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 0f312f19f5..0013f38d89 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -167,7 +167,8 @@ do
local line1 = lines[1]:gsub('(%c)', '\022%1')
-- nvim_input() is affected by mappings,
-- so use nvim_feedkeys() with "n" flag to ignore mappings.
- vim.api.nvim_feedkeys(line1, 'n', true)
+ -- "t" flag is also needed so the pasted text is saved in cmdline history.
+ vim.api.nvim_feedkeys(line1, 'nt', true)
end
return true
end
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index af6cee7e90..114413365f 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -1108,6 +1108,14 @@ describe('API', function()
nvim('paste', 'a', true, -1)
eq('a', funcs.getcmdline())
end)
+ it('pasted text is saved in cmdline history when <CR> comes from mapping #20957', function()
+ command('cnoremap <CR> <CR>')
+ feed(':')
+ nvim('paste', 'echo', true, -1)
+ eq('', funcs.histget(':'))
+ feed('<CR>')
+ eq('echo', funcs.histget(':'))
+ end)
it('pasting with empty last chunk in Cmdline mode', function()
local screen = Screen.new(20, 4)
screen:attach()