patch 9.2.0533: '[ mark moved to end of inserted text after CTRL-R CTRL-P paste
Commit: https://github.com/vim/vim/commit/bc7805323f54405e2e746efde3901b0b6aefe6ff Author: Hirohito Higashi <[email protected]> Date: Mon May 25 15:36:30 2026 +0000 patch 9.2.0533: '[ mark moved to end of inserted text after CTRL-R CTRL-P paste Problem: After CTRL-R CTRL-P (or CTRL-R CTRL-O) pastes a register into Insert mode, a follow-up edit such as backspace makes stop_arrow() rewrite Insstart with the post-paste cursor position. As a result the '[ mark points at the end of the inserted text instead of its start (agguser, after 9.2.0384) Solution: In stop_arrow(), only pull Insstart back when the cursor moved above the previous Insstart, so a line-start backspace can still save the joined range (#20031) without disturbing the start position for inserts that advance the cursor (Hirohito Higashi). related: #20031 fixes: #20130 closes: #20322 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> Signed-off-by: Hirohito Higashi <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/src/edit.c b/src/edit.c index 512c0b23c..d59db1afd 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 6511e178c..af8359e0d 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\<C-r>\<C-p>\"\<BS>\<Esc>", '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 69f0ef22b..2056d7110 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, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wRXUH-0060b2-2r%40256bit.org.
