Patch 9.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)
Files:      src/edit.c, src/main.c, src/testdir/test_edit.vim,
            src/testdir/dumps/Test_edit_ctlr_r_failed_1.dump


*** ../vim-9.0.1427/src/edit.c  2023-02-26 14:47:20.355108904 +0000
--- src/edit.c  2023-03-25 20:01:09.225269519 +0000
***************
*** 3688,3693 ****
--- 3688,3694 ----
        else
        {
            --curwin->w_cursor.col;
+           curwin->w_valid &= ~(VALID_WCOL|VALID_VIRTCOL);
            // Correct cursor for multi-byte character.
            if (has_mbyte)
                mb_adjust_cursor();
*** ../vim-9.0.1427/src/main.c  2023-01-14 12:32:24.215984102 +0000
--- src/main.c  2023-03-25 20:03:47.825045894 +0000
***************
*** 305,311 ****
        params.want_full_screen = FALSE;
  
      /*
!      * When certain to start the GUI, don't check capabilities of terminal.
       * For GTK we can't be sure, but when started from the desktop it doesn't
       * make sense to try using a terminal.
       */
--- 305,311 ----
        params.want_full_screen = FALSE;
  
      /*
!      * 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,1296 ****
--- 1290,1300 ----
         * update cursor and redraw.
         */
        if (skip_redraw || exmode_active)
+       {
            skip_redraw = FALSE;
+           setcursor();
+           cursor_on();
+       }
        else if (do_redraw || stuff_empty())
        {
  #ifdef FEAT_GUI
*** ../vim-9.0.1427/src/testdir/test_edit.vim   2023-02-26 14:47:20.355108904 
+0000
--- src/testdir/test_edit.vim   2023-03-25 19:59:38.377350197 +0000
***************
*** 5,10 ****
--- 5,11 ----
  endif
  
  source check.vim
+ source screendump.vim
  
  " Needed for testing basic rightleft: Test_edit_rightleft
  source view_util.vim
***************
*** 1957,1962 ****
--- 1958,1979 ----
    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.
*** ../vim-9.0.1427/src/testdir/dumps/Test_edit_ctlr_r_failed_1.dump    
2023-03-25 20:05:43.436857947 +0000
--- src/testdir/dumps/Test_edit_ctlr_r_failed_1.dump    2023-03-25 
19:59:46.297343088 +0000
***************
*** 0 ****
--- 1,6 ----
+ >:+0&#ffffff0| @58
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ |~| @58
+ | +0#0000000&@59
*** ../vim-9.0.1427/src/version.c       2023-03-25 11:31:29.115831726 +0000
--- src/version.c       2023-03-25 19:46:07.630237009 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1428,
  /**/

-- 
"A mouse can be just as dangerous as a bullet or a bomb."
             (US Representative Lamar Smith, R-Texas)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230325200725.11A061C03FD%40moolenaar.net.

Raspunde prin e-mail lui