]> granicus.if.org Git - vim/commitdiff
patch 9.0.1385: g'Esc is considered an error v9.0.1385
authorzeertzjq <zeertzjq@outlook.com>
Sun, 5 Mar 2023 21:15:06 +0000 (21:15 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 5 Mar 2023 21:15:06 +0000 (21:15 +0000)
Problem:    g'Esc is considered an error.
Solution:   Make g'Esc silently abandon the command. (closes #12110)

src/normal.c
src/testdir/test_normal.vim
src/version.c

index da01480ebcae53fe7796fb04797a1a493e6120a8..6f947a6c3c71d9ebd91872a16e31dedacd7f3c3b 100644 (file)
@@ -899,7 +899,7 @@ normal_cmd(
 
     State = MODE_NORMAL;
 
-    if (ca.nchar == ESC)
+    if (ca.nchar == ESC || ca.extra_char == ESC)
     {
        clearop(oap);
        if (restart_edit == 0 && goto_im())
@@ -984,7 +984,8 @@ normal_end:
 #ifdef CURSOR_SHAPE
     // Redraw the cursor with another shape, if we were in Operator-pending
     // mode or did a replace command.
-    if (prev_finish_op || ca.cmdchar == 'r')
+    if (prev_finish_op || ca.cmdchar == 'r'
+                                    || (ca.cmdchar == 'g' && ca.nchar == 'r'))
     {
        ui_cursor_shape();              // may show different cursor shape
 # ifdef FEAT_MOUSESHAPE
@@ -5025,7 +5026,7 @@ nv_vreplace(cmdarg_T *cap)
        return;
     }
 
-    if (checkclearopq(cap->oap) || cap->extra_char == ESC)
+    if (checkclearopq(cap->oap))
        return;
 
     if (!curbuf->b_p_ma)
@@ -5903,7 +5904,7 @@ nv_g_cmd(cmdarg_T *cap)
        else
 #endif
     // "g^A/g^X": sequentially increment visually selected region
-            if (VIsual_active)
+       if (VIsual_active)
        {
            cap->arg = TRUE;
            cap->cmdchar = cap->nchar;
index 6db5af76ab3af284e209cc8c293585f4ba46c7a4..7b775fe00f4c45835b103bbe42c5113aa633e13d 100644 (file)
@@ -2526,6 +2526,8 @@ func Test_normal33_g_cmd2()
   norm! g'a
   call assert_equal('>', a[-1:])
   call assert_equal(1, line('.'))
+  call assert_nobeep("normal! g`\<Esc>")
+  call assert_nobeep("normal! g'\<Esc>")
 
   " Test for g; and g,
   norm! g;
@@ -3305,7 +3307,8 @@ func Test_gr_command()
   set modifiable&
 
   call assert_nobeep("normal! gr\<Esc>")
-  call assert_beeps("normal! cgr\<Esc>")
+  call assert_nobeep("normal! cgr\<Esc>")
+  call assert_beeps("normal! cgrx")
 
   call assert_equal('zxxxx line    l', getline(1))
   exe "normal! 2|gr\<C-V>\<Esc>"
@@ -3921,4 +3924,36 @@ func Test_mouse_shape_after_failed_change()
   call delete('Xmouseshapes')
 endfunc
 
+" Test that mouse shape is restored to Normal mode after cancelling "gr".
+func Test_mouse_shape_after_cancelling_gr()
+  CheckFeature mouseshape
+  CheckCanRunGui
+
+  let lines =<< trim END
+    vim9script
+    var mouse_shapes = []
+
+    feedkeys('gr')
+    timer_start(50, (_) => {
+      mouse_shapes += [getmouseshape()]
+      timer_start(50, (_) => {
+        feedkeys("\<Esc>")
+        timer_start(50, (_) => {
+          mouse_shapes += [getmouseshape()]
+          timer_start(50, (_) => {
+            writefile(mouse_shapes, 'Xmouseshapes')
+            quit
+          })
+        })
+      })
+    })
+  END
+  call writefile(lines, 'Xmouseshape.vim', 'D')
+  call RunVim([], [], "-g -S Xmouseshape.vim")
+  sleep 300m
+  call assert_equal(['beam', 'arrow'], readfile('Xmouseshapes'))
+
+  call delete('Xmouseshapes')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 0090eed8472caee5a48bdd3336864af62de9131b..4288f31a352cc27106523d67c22f50ae14785b0a 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1385,
 /**/
     1384,
 /**/