0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

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 #12354)
This commit is contained in:
zeertzjq
2023-05-07 17:39:23 +01:00
committed by Bram Moolenaar
parent 048d9d2521
commit 30b6d6104c
4 changed files with 34 additions and 5 deletions

View File

@@ -43,8 +43,8 @@ static buffheader_T recordbuff = {{NULL, {NUL}}, NULL, 0, 0};
static int typeahead_char = 0; // typeahead char that's not flushed static int typeahead_char = 0; // typeahead char that's not flushed
/* /*
* when block_redo is TRUE redo buffer will not be changed * When block_redo is TRUE the redo buffer will not be changed.
* used by edit() to repeat insertions and 'V' command for redoing * Used by edit() to repeat insertions.
*/ */
static int block_redo = FALSE; static int block_redo = FALSE;
@@ -609,11 +609,14 @@ AppendToRedobuffLit(
void void
AppendToRedobuffSpec(char_u *s) AppendToRedobuffSpec(char_u *s)
{ {
if (block_redo)
return;
while (*s != NUL) while (*s != NUL)
{ {
if (*s == K_SPECIAL && s[1] != NUL && s[2] != NUL) if (*s == K_SPECIAL && s[1] != NUL && s[2] != NUL)
{ {
// insert special key literally // Insert special key literally.
add_buff(&redobuff, s, 3L); add_buff(&redobuff, s, 3L);
s += 3; s += 3;
} }

View File

@@ -3701,6 +3701,9 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
ResetRedobuff(); ResetRedobuff();
else else
{ {
if (cap->cmdchar == ':')
AppendToRedobuffLit(repeat_cmdline, -1);
else
AppendToRedobuffSpec(repeat_cmdline); AppendToRedobuffSpec(repeat_cmdline);
AppendToRedobuff(NL_STR); AppendToRedobuff(NL_STR);
VIM_CLEAR(repeat_cmdline); VIM_CLEAR(repeat_cmdline);

View File

@@ -3635,11 +3635,32 @@ func Test_horiz_motion()
bwipe! bwipe!
endfunc endfunc
" Test for using a : command in operator pending mode " Test for using a ":" command in operator pending mode
func Test_normal_colon_op() func Test_normal_colon_op()
new new
call setline(1, ['one', 'two']) call setline(1, ['one', 'two'])
call assert_beeps("normal! Gc:d\<CR>") 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! bwipe!
endfunc endfunc

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1521,
/**/ /**/
1520, 1520,
/**/ /**/