diff options
author | Bram Moolenaar <Bram@vim.org> | 2023-03-25 20:06:49 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-03-25 20:06:49 +0000 |
commit | c174c2e58c9e24a75b189e01143e6d057b84e96e (patch) | |
tree | deb9aa525c7fd782b00c18c9f69a53a091aa893a /src | |
parent | 1f76138ff1d08a8474cfcaf743448caf679416a3 (diff) |
patch 9.0.1428: cursor in wrong position when leaving insert modev9.0.1428
Problem: Cursor in wrong position when leaving insert mode.
Solution: Update the w_valid flags. Position the cursor also when not
redrawing. (closes #12137)
Diffstat (limited to 'src')
-rw-r--r-- | src/edit.c | 1 | ||||
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/testdir/dumps/Test_edit_ctlr_r_failed_1.dump | 6 | ||||
-rw-r--r-- | src/testdir/test_edit.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 31 insertions, 1 deletions
diff --git a/src/edit.c b/src/edit.c index 212efae3d4..84b6eef4b6 100644 --- a/src/edit.c +++ b/src/edit.c @@ -3688,6 +3688,7 @@ ins_esc( else { --curwin->w_cursor.col; + curwin->w_valid &= ~(VALID_WCOL|VALID_VIRTCOL); // Correct cursor for multi-byte character. if (has_mbyte) mb_adjust_cursor(); diff --git a/src/main.c b/src/main.c index d1c42ed120..f5d3cb4193 100644 --- a/src/main.c +++ b/src/main.c @@ -305,7 +305,7 @@ main params.want_full_screen = FALSE; /* - * When certain to start the GUI, don't check capabilities of terminal. + * When certain to start the GUI, don't check terminal capabilities. * For GTK we can't be sure, but when started from the desktop it doesn't * make sense to try using a terminal. */ @@ -1290,7 +1290,11 @@ main_loop( * update cursor and redraw. */ if (skip_redraw || exmode_active) + { skip_redraw = FALSE; + setcursor(); + cursor_on(); + } else if (do_redraw || stuff_empty()) { #ifdef FEAT_GUI diff --git a/src/testdir/dumps/Test_edit_ctlr_r_failed_1.dump b/src/testdir/dumps/Test_edit_ctlr_r_failed_1.dump new file mode 100644 index 0000000000..26eb1a4c1d --- /dev/null +++ b/src/testdir/dumps/Test_edit_ctlr_r_failed_1.dump @@ -0,0 +1,6 @@ +>:+0&#ffffff0| @58 +|~+0#4040ff13&| @58 +|~| @58 +|~| @58 +|~| @58 +| +0#0000000&@59 diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim index 79e3c3fd22..3ce5421142 100644 --- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -5,6 +5,7 @@ if exists("+t_kD") endif source check.vim +source screendump.vim " Needed for testing basic rightleft: Test_edit_rightleft source view_util.vim @@ -1957,6 +1958,22 @@ func Test_edit_insert_reg() close! endfunc +" Test for positioning cursor after CTRL-R expression failed +func Test_edit_ctrl_r_failed() + CheckRunVimInTerminal + + let buf = RunVimInTerminal('', #{rows: 6, cols: 60}) + + " trying to insert a dictionary produces an error + call term_sendkeys(buf, "i\<C-R>={}\<CR>") + + " ending Insert mode should put the cursor back on the ':' + call term_sendkeys(buf, ":\<Esc>") + call VerifyScreenDump(buf, 'Test_edit_ctlr_r_failed_1', {}) + + call StopVimInTerminal(buf) +endfunc + " When a character is inserted at the last position of the last line in a " window, the window contents should be scrolled one line up. If the top line " is part of a fold, then the entire fold should be scrolled up. diff --git a/src/version.c b/src/version.c index 0a4a8a0524..f25f59fc84 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1428, +/**/ 1427, /**/ 1426, |