vim-patch:9.2.0621: 'autoindent' not stripped with virtualedit=onemore (#40203)

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: vim/vim#20476

4b13277edd
This commit is contained in:
zeertzjq
2026-06-12 18:53:35 +08:00
committed by GitHub
parent 8c4578cc4f
commit 00289fa20a
2 changed files with 17 additions and 0 deletions

View File

@@ -2311,6 +2311,9 @@ static void stop_insert(pos_T *end_insert_pos, int esc, int nomove)
if (*skipwhite(get_cursor_line_ptr() + strip_col) == NUL) {
curwin->w_cursor.col = strip_col;
while (true) {
if (gchar_cursor() == NUL && curwin->w_cursor.col > 0) {
curwin->w_cursor.col--;
}
cc = gchar_cursor();
if (!ascii_iswhite(cc)) {
break;

View 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