]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0621: 'autoindent' not stripped with virtualedit=onemore v9.2.0621
authorzeertzjq <zeertzjq@outlook.com>
Fri, 12 Jun 2026 09:32:10 +0000 (09:32 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 12 Jun 2026 09:32:10 +0000 (09:32 +0000)
Problem:  'autoindent' not stripped with virtualedit=onemore (after
          9.2.0510).
Solution: Restore the decrement of cursor column when it's on NUL.

fixes:  neovim/neovim#40183
closes: #20476

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/edit.c
src/testdir/test_virtualedit.vim
src/version.c

index 3eba12dab54369f85f77163bf5a730f6f3ae3342..c10654e3681779f072c7cd44d9c4e64793eebf3f 100644 (file)
@@ -2670,6 +2670,8 @@ stop_insert(
                curwin->w_cursor.col = strip_col;
                for (;;)
                {
+                   if (gchar_cursor() == NUL && curwin->w_cursor.col > 0)
+                       --curwin->w_cursor.col;
                    cc = gchar_cursor();
                    if (!VIM_ISWHITE(cc))
                        break;
index 902bbbfd1e0a4354a914640ee8701ad9b9a2a0ca..24a1903031dc55c280ee32c337ff74e1004f4760 100644 (file)
@@ -788,4 +788,18 @@ func Test_set_virtualedit_on_mode_change()
   bwipe!
 endfunc
 
+func Test_strip_autoindent_with_virtualedit_onemore()
+  new
+  setlocal autoindent virtualedit=onemore
+  call feedkeys("i   x\<CR>\<Esc>", 'tnix')
+  call assert_equal(['   x', ''], getline(1, '$'))
+
+  %delete _
+  setlocal virtualedit&
+  call feedkeys("i   x\<CR>\<Esc>", 'tnix')
+  call assert_equal(['   x', ''], getline(1, '$'))
+
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 8538d4ed35120d22942e6a34301840be170767d8..fac15c00f31f04dd93b7ad1095f444d692cb25e1 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    621,
 /**/
     620,
 /**/