diff --git a/src/edit.c b/src/edit.c index 60cae0e15c..f15cc55f32 100644 --- a/src/edit.c +++ b/src/edit.c @@ -2502,7 +2502,12 @@ stop_arrow(void) else if (ins_need_undo) { if (u_save_cursor() == OK) + { + // A command or event may have moved the cursor after syncing undo. + Insstart = curwin->w_cursor; + Insstart_textlen = (colnr_T)linetabsize_str(ml_get_curline()); ins_need_undo = FALSE; + } } #ifdef FEAT_FOLDING diff --git a/src/testdir/test_undo.vim b/src/testdir/test_undo.vim index ad724aa04d..97b77f423d 100644 --- a/src/testdir/test_undo.vim +++ b/src/testdir/test_undo.vim @@ -924,5 +924,19 @@ func Test_restore_cursor_position_after_undo() bw! endfunc +func Test_undo_line_backspace_after_insert_cmd_cursor_movement() + new + setlocal backspace=eol undolevels=100 + call setline(1, ['', '', 'abc', 'def']) + call cursor(4, 1) + + let v:errmsg = '' + call feedkeys("i\setlocal undolevels=101 | call cursor(3, 1)\" + \ .. "\\\u", 'xt') + + call assert_equal('', v:errmsg) + call assert_equal(['', '', 'abc', 'def'], getline(1, '$')) + bwipe! +endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 895c22e9c0..2a8b84404f 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 */ +/**/ + 384, /**/ 383, /**/