aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-05-08 00:41:18 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-05-08 01:12:09 +0800
commit5844af0d524956b55100e4350934237e4a12a147 (patch)
tree5d9f239d6421d94f2327df672500332ec72b099f
parent32331378134599ece34298f866889b4b311d7b79 (diff)
downloadrneovim-5844af0d524956b55100e4350934237e4a12a147.tar.gz
rneovim-5844af0d524956b55100e4350934237e4a12a147.tar.bz2
rneovim-5844af0d524956b55100e4350934237e4a12a147.zip
vim-patch:9.0.1521: failing redo of command with control characters
Problem: Failing redo of command with control characters. Solution: Use AppendToRedobuffLit() for colon commands. (closes vim/vim#12354) https://github.com/vim/vim/commit/30b6d6104c3d541c41c868989c020b743e01af08
-rw-r--r--src/nvim/getchar.c8
-rw-r--r--src/nvim/ops.c6
-rw-r--r--test/old/testdir/test_normal.vim23
3 files changed, 33 insertions, 4 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index c070e53089..ca555937ab 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -92,8 +92,8 @@ static buffheader_T readbuf2 = { { NULL, { NUL } }, NULL, 0, 0 };
static int typeahead_char = 0; // typeahead char that's not flushed
-// when block_redo is true redo buffer will not be changed
-// used by edit() to repeat insertions and 'V' command for redoing
+/// When block_redo is true the redo buffer will not be changed.
+/// Used by edit() to repeat insertions.
static int block_redo = false;
static int KeyNoremap = 0; // remapping flags
@@ -558,6 +558,10 @@ void AppendToRedobuffLit(const char *str, int len)
/// and escaping other K_SPECIAL bytes.
void AppendToRedobuffSpec(const char *s)
{
+ if (block_redo) {
+ return;
+ }
+
while (*s != NUL) {
if ((uint8_t)(*s) == K_SPECIAL && s[1] != NUL && s[2] != NUL) {
// Insert special key literally.
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index ef26d5900d..c1511ab8da 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -5858,7 +5858,11 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
if (repeat_cmdline == NULL) {
ResetRedobuff();
} else {
- AppendToRedobuffSpec(repeat_cmdline);
+ if (cap->cmdchar == ':') {
+ AppendToRedobuffLit(repeat_cmdline, -1);
+ } else {
+ AppendToRedobuffSpec(repeat_cmdline);
+ }
AppendToRedobuff(NL_STR);
XFREE_CLEAR(repeat_cmdline);
}
diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim
index 330a16dffb..a854c9538f 100644
--- a/test/old/testdir/test_normal.vim
+++ b/test/old/testdir/test_normal.vim
@@ -3648,11 +3648,32 @@ func Test_horiz_motion()
bwipe!
endfunc
-" Test for using a : command in operator pending mode
+" Test for using a ":" command in operator pending mode
func Test_normal_colon_op()
new
call setline(1, ['one', 'two'])
call assert_beeps("normal! Gc:d\<CR>")
+ call assert_equal(['one'], getline(1, '$'))
+
+ call setline(1, ['one…two…three!'])
+ normal! $
+ " Using ":" as a movement is characterwise exclusive
+ call feedkeys("d:normal! F…\<CR>", 'xt')
+ call assert_equal(['one…two!'], getline(1, '$'))
+ " Check that redoing a command with 0x80 bytes works
+ call feedkeys('.', 'xt')
+ call assert_equal(['one!'], getline(1, '$'))
+
+ call setline(1, ['one', 'two', 'three', 'four', 'five'])
+ " Add this to the command history
+ call feedkeys(":normal! G0\<CR>", 'xt')
+ " Use :normal! with control characters in operator pending mode
+ call feedkeys("d:normal! \<C-V>\<C-P>\<C-V>\<C-P>\<CR>", 'xt')
+ call assert_equal(['one', 'two', 'five'], getline(1, '$'))
+ " Check that redoing a command with control characters works
+ call feedkeys('.', 'xt')
+ call assert_equal(['five'], getline(1, '$'))
+
bwipe!
endfunc