feat(editor)!: insert-mode ctrl-r should work like paste #35477

Problem:
insert-mode ctrl-r input is treated like raw user input, which is almost
never useful. This means any newlines in the input are affected by
autoindent, etc., which is:
- slow
- usually breaks the formatting of the input

Solution:
- ctrl-r should be treated like a paste, not user-input.
- does not affect `<c-r>=`, so `<c-r>=@x` can still be used to get the
  old behavior.

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
Shadman
2025-09-02 10:05:16 +06:00
committed by GitHub
parent b4d21f141c
commit 79bfeecdb4
10 changed files with 70 additions and 21 deletions

View File

@@ -83,6 +83,36 @@ describe('insert-mode', function()
{5:-- INSERT --} |
]])
end)
it('inserts named registers literally', function()
local screen = Screen.new(50, 6)
-- regular text without special charecter command
command('let @a = "test"')
feed('i<C-R>a<ESC>')
screen:expect([[
tes^t |
{1:~ }|*4
|
]])
-- text with backspace character gets written literally by default
command('let @a = "test\\<C-H>"')
feed('cc<C-R>a<ESC>')
screen:expect([[
test{18:^^H} |
{1:~ }|*4
|
]])
-- =@reg<CR> can be used to get effect of keypress
command('let @a = "test\\<C-H>"')
feed('cc<C-R>=@a<CR><ESC>')
screen:expect([[
te^s |
{1:~ }|*4
|
]])
end)
end)
describe('Ctrl-O', function()