neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit e263afc0e972d11d3b9b663c3ac0b5575c4deb88
parent 3470a9c3de076ec3170525c3de66544f9836c775
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Tue, 15 Mar 2022 06:04:50 +0800

fix(paste): escape control characters in Cmdline mode

Diffstat:
Mruntime/lua/vim/_editor.lua | 3++-
Mtest/functional/api/vim_spec.lua | 12++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua @@ -175,7 +175,8 @@ do if not got_line1 then got_line1 = (#lines > 1) vim.api.nvim_set_option('paste', true) -- For nvim_input(). - local line1 = lines[1]:gsub('<', '<lt>'):gsub('[\r\n\012\027]', ' ') -- Scrub. + -- Escape "<" and control characters + local line1 = lines[1]:gsub('<', '<lt>'):gsub('(%c)', '\022%1') vim.api.nvim_input(line1) vim.api.nvim_set_option('paste', false) end diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua @@ -1097,6 +1097,18 @@ describe('API', function() :Foo^ | ]]) end) + it('pasting text with control characters in Cmdline mode', function() + local screen = Screen.new(20, 4) + screen:attach() + feed(':') + nvim('paste', 'normal! \023\022\006\027', true, -1) + screen:expect([[ + | + ~ | + ~ | + :normal! ^W^V^F^[^ | + ]]) + end) it('crlf=false does not break lines at CR, CRLF', function() nvim('paste', 'line 1\r\n\r\rline 2\nline 3\rline 4\r', false, -1) expect('line 1\r\n\r\rline 2\nline 3\rline 4\r')