Commit: patch 9.2.0549: Cursor wrong after autoindent strip is skipped

4 views
Skip to first unread message

Christian Brabandt

unread,
May 28, 2026, 4:30:13 PMMay 28
to vim...@googlegroups.com
patch 9.2.0549: Cursor wrong after autoindent strip is skipped

Commit: https://github.com/vim/vim/commit/179f9efc7ec49f7fb9965d86734973bdac135870
Author: glepnir <gleph...@gmail.com>
Date: Thu May 28 20:13:48 2026 +0000

patch 9.2.0549: Cursor wrong after autoindent strip is skipped

Problem: cursor lands on the wrong line when a <Cmd> 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 <gleph...@gmail.com>
Signed-off-by: Kristijan Husak <husakkr...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/edit.c b/src/edit.c
index d59db1afd..2b839d7f5 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 af8359e0d..f76b9196f 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 <buffer> <F3> {}<Left><CR><Cmd>normal! ==<CR><Up><End><CR>
+
+ call setline(1, '')
+ call feedkeys("i\<F3>\<Esc>", '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\<Esc>", 'tnix')
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 7b71661ea..575332e4e 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,
/**/
Reply all
Reply to author
Forward
0 new messages