From: glepnir Date: Thu, 28 May 2026 20:13:48 +0000 (+0000) Subject: patch 9.2.0549: Cursor wrong after autoindent strip is skipped X-Git-Tag: v9.2.0549^0 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=179f9efc7ec49f7fb9965d86734973bdac135870;p=thirdparty%2Fvim.git patch 9.2.0549: Cursor wrong after autoindent strip is skipped Problem: cursor lands on the wrong line when a mapping or autocmd modifies lines during insert and the strip is skipped (after v9.2.0510) Solution: Restore cursor to tpos when skipwhite skips the strip, instead of leaving it at end_insert_pos (glepnir). related: #20290 closes: #20332 Signed-off-by: glepnir Signed-off-by: Kristijan Husak Signed-off-by: Christian Brabandt --- diff --git a/src/edit.c b/src/edit.c index d59db1afd3..2b839d7f5c 100644 --- a/src/edit.c +++ b/src/edit.c @@ -2657,6 +2657,9 @@ stop_insert( if (VIsual_active) check_visual_pos(); } + else + // Non-whitespace follows, keep original cursor. + curwin->w_cursor = tpos; } } did_ai = FALSE; diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim index af8359e0d4..f76b9196fe 100644 --- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -2496,4 +2496,22 @@ func Test_open_square_mark_after_ctrl_r_ctrl_p_paste() bwipe! endfunc +func Test_autoindent_no_strip_cross_line() + new + setlocal autoindent + inoremap {}normal! == + + call setline(1, '') + call feedkeys("i\\", 'tx') + + call assert_equal('{', getline(1)) + call assert_equal('', getline(2)) + call assert_equal('}', getline(3)) + call assert_equal([0, 2, 1, 0], getpos('.')) + + " Overwrite @. register with simple content to avoid affecting later tests. + call feedkeys("Go\", 'tnix') + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 7b71661ea8..575332e4e6 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 */ +/**/ + 549, /**/ 548, /**/