0
0
mirror of https://github.com/vim/vim.git synced 2025-08-26 20:03:41 -04:00

patch 9.1.1216: Pasting the '.' register multiple times may not work

Problem:  Pasting the '.' register multiple times may work incorrectly
          when the last insert starts with Ctrl-D and ends with '0'.
          (after 9.1.1212)
Solution: Restore the missing assignment (zeertzjq).

closes: #16908

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq 2025-03-17 21:02:50 +01:00 committed by Christian Brabandt
parent ad2f6b6662
commit 61b3544424
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
4 changed files with 40 additions and 7 deletions

View File

@ -2934,7 +2934,7 @@ stuff_inserted(
char_u *p;
// look for the last ESC in 'insert'
for (p = insert->string + (insert->length - 1); p >= insert->string; --p)
for (p = insert->string + insert->length - 1; p >= insert->string; --p)
{
if (*p == ESC)
{
@ -2942,12 +2942,16 @@ stuff_inserted(
break;
}
}
}
if (insert->length > 0)
{
char_u *p = insert->string + insert->length - 1;
// when the last char is either "0" or "^" it will be quoted if no ESC
// comes after it OR if it will insert more than once and "ptr"
// starts with ^D. -- Acevedo
if (p >= insert->string
&& (*p == '0' || *p == '^')
if ((*p == '0' || *p == '^')
&& (no_esc || (*insert->string == Ctrl_D && count > 1)))
{
last = *p;

View File

@ -204,7 +204,7 @@ get_recorded(void)
get_inserted(void)
{
size_t len = 0;
char_u* str = get_buffcont(&redobuff, FALSE, &len);
char_u *str = get_buffcont(&redobuff, FALSE, &len);
string_T ret = { str, len };
return ret;
}

View File

@ -328,4 +328,31 @@ func Test_put_list()
bw!
endfunc
" Test pasting the '.' register
func Test_put_inserted()
new
for s in ['', '…', '0', '^', '+0', '+^', '…0', '…^']
call setline(1, 'foobar')
exe $"normal! A{s}\<Esc>"
call assert_equal($'foobar{s}', getline(1))
normal! ".p
call assert_equal($'foobar{s}{s}', getline(1))
normal! ".2p
call assert_equal($'foobar{s}{s}{s}{s}', getline(1))
endfor
for s in ['0', '^', '+0', '+^', '…0', '…^']
call setline(1, "\t\t\t\t\tfoobar")
exe $"normal! A\<C-D>{s}\<Esc>"
call assert_equal($"\t\t\t\tfoobar{s}", getline(1))
normal! ".p
call assert_equal($"\t\t\tfoobar{s}{s}", getline(1))
normal! ".2p
call assert_equal($"\tfoobar{s}{s}{s}{s}", getline(1))
endfor
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

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