diff --git a/src/edit.c b/src/edit.c index 512c0b23c4..d59db1afd3 100644 --- a/src/edit.c +++ b/src/edit.c @@ -2512,11 +2512,16 @@ stop_arrow(void) { if (u_save_cursor() == OK) { - // A command or event may have moved the cursor or edited the - // buffer. Update Insstart so that later edits can properly decide - // whether an extra undo entry is needed. - Insstart = curwin->w_cursor; - Insstart_textlen = (colnr_T)linetabsize_str(ml_get_curline()); + // A command or event may have moved the cursor before the next + // edit. Pull Insstart back only when the cursor moved above it, + // so that later edits can properly decide whether an extra undo + // entry is needed. Advancing Insstart would mis-place '[ after a + // register paste. + if (LT_POS(curwin->w_cursor, Insstart)) + { + Insstart = curwin->w_cursor; + Insstart_textlen = (colnr_T)linetabsize_str(ml_get_curline()); + } ins_need_undo = FALSE; } } diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim index 6511e178cf..af8359e0d4 100644 --- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -2482,4 +2482,18 @@ func Test_autoindent_no_strip_after_cursorholdi() bwipe! endfunc +" Issue #20130: '[ must mark the start of the paste after CTRL-R CTRL-P + edit. +func Test_open_square_mark_after_ctrl_r_ctrl_p_paste() + new + call setline(1, ['a', 'b', 'c', 'd']) + call cursor(4, 1) + + call feedkeys("Vggyjo\\\"\\", 'xt') + + call assert_equal(['a', 'b', 'a', 'b', 'c', 'd', 'c', 'd'], + \ getline(1, '$')) + call assert_equal([0, 3, 1, 0], getpos("'[")) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 69f0ef22b8..2056d71108 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 */ +/**/ + 533, /**/ 532, /**/