]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0549: Cursor wrong after autoindent strip is skipped v9.2.0549
authorglepnir <glephunter@gmail.com>
Thu, 28 May 2026 20:13:48 +0000 (20:13 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 28 May 2026 20:13:48 +0000 (20:13 +0000)
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 <glephunter@gmail.com>
Signed-off-by: Kristijan Husak <husakkristijan@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/edit.c
src/testdir/test_edit.vim
src/version.c

index d59db1afd3a596d9415649cfab4f71431bc08676..2b839d7f5c416e4af9edef613b31e0274f5ccab1 100644 (file)
@@ -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;
index af8359e0d4fdc62b4e313deb5b27ed8293fd87ff..f76b9196febbf0ba0c1daa2f73ce38ef8ce17552 100644 (file)
@@ -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
index 7b71661ea8fa5c4fe320c917318508625e3559a3..575332e4e6ba501178dc1ad3c85847eac7cc0847 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    549,
 /**/
     548,
 /**/