From: zeertzjq Date: Mon, 11 May 2026 16:49:19 +0000 (+0000) Subject: patch 9.2.0473: Pasting ". register without autocommands breaks TextPut* X-Git-Tag: v9.2.0473^0 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a70b7a85afad9dc8eeae2a97142dc744cf3205e6;p=thirdparty%2Fvim.git patch 9.2.0473: Pasting ". register without autocommands breaks TextPut* Problem: Pasting ". register without TextPut* autocommands breaks subsequent TextPut* autocommands (after 9.2.0470). Solution: Only decrement add_last_insert if it has been incremented (zeertzjq). closes: #20192 Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt --- diff --git a/src/register.c b/src/register.c index 44e6aba6f5..86ac02cfc1 100644 --- a/src/register.c +++ b/src/register.c @@ -1736,7 +1736,8 @@ do_put( stuffcharReadbuff(VIsual_mode); #ifdef FEAT_EVAL - if (has_textputpre() || has_textputpost()) + bool has_textput_events = has_textputpre() || has_textputpost(); + if (has_textput_events) add_last_insert++; #endif @@ -1748,11 +1749,10 @@ do_put( // TextPutPost after TextPutPre. if (has_textputpre()) put_do_autocmd('.', NULL, NULL, false, dir); - if (has_textputpost()) put_do_autocmd('.', NULL, NULL, true, dir); - if (--add_last_insert == 0) + if (has_textput_events && --add_last_insert == 0) ga_clear(&last_insert_ga); #endif diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index 2a3616893f..ecd5791c90 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -6069,22 +6069,27 @@ func Test_TextPutX() au! TextPutPre let g:pre_event = [] - " Test that recursive ". register calls have the same contents for post and - " pre - au TextPutPre * put . | let g:pre_event = copy(v:event) - au TextPutPost * let g:post_event = copy(v:event) + for round in range(2) + " Recursive ". register calls have the same contents for post and pre. + au TextPutPre * put . | let g:pre_event = copy(v:event) + au TextPutPost * let g:post_event = copy(v:event) - call feedkeys("iinserted\", 'x') - norm! ".p + call feedkeys("iinserted\", 'x') + norm! ".p - call assert_equal( - \ #{regcontents: ["inserted"], regname: '.', - \ operator: 'p', regtype: 'v', visual: v:false}, - \ g:pre_event) - call assert_equal(g:pre_event, g:post_event) + call assert_equal( + \ #{regcontents: ["inserted"], regname: '.', + \ operator: 'p', regtype: 'v', visual: v:false}, + \ g:pre_event) + call assert_equal(g:pre_event, g:post_event) - au! TextPutPre - au! TextPutPost + au! TextPutPre + au! TextPutPost + + " Pasting ". register without TextPutPre/TextPutPost autocommands should + " not interfere with these autocommands in the next round. + norm! ".p + endfor unlet g:post_event unlet g:pre_event diff --git a/src/version.c b/src/version.c index 3aff29a296..f96e170e4e 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 473, /**/ 472, /**/