]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1490: the ModeChanged event may be triggered too often v9.0.1490
authorzeertzjq <zeertzjq@outlook.com>
Wed, 26 Apr 2023 15:50:19 +0000 (16:50 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 26 Apr 2023 15:50:19 +0000 (16:50 +0100)
Problem:    The ModeChanged event may be triggered too often.
Solution:   Only trigger ModeChanged when no operator is pending.
            (closes #12298)

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

index 1b5326b1362dbb3d98647b8830d41b03aea10ba8..2f3d12a41b2a7b7efd8b4feb903f38e5e2d0a380 100644 (file)
@@ -975,12 +975,15 @@ normal_end:
        reset_reg_var();
 #endif
 
-    // Reset finish_op, in case it was set
 #ifdef CURSOR_SHAPE
     int prev_finish_op = finish_op;
 #endif
-    finish_op = FALSE;
-    may_trigger_modechanged();
+    if (oap->op_type == OP_NOP)
+    {
+       // Reset finish_op, in case it was set
+       finish_op = FALSE;
+       may_trigger_modechanged();
+    }
 #ifdef CURSOR_SHAPE
     // Redraw the cursor with another shape, if we were in Operator-pending
     // mode or did a replace command.
@@ -995,7 +998,7 @@ normal_end:
 #endif
 
     if (oap->op_type == OP_NOP && oap->regname == 0
-           && ca.cmdchar != K_CURSORHOLD)
+                                                && ca.cmdchar != K_CURSORHOLD)
        clear_showcmd();
 
     checkpcmark();             // check if we moved since setting pcmark
@@ -1496,9 +1499,9 @@ prep_redo_num2(
 }
 
 /*
- * check for operator active and clear it
+ * Check for operator active and clear it.
  *
- * return TRUE if operator was active
+ * Beep and return TRUE if an operator was active.
  */
     static int
 checkclearop(oparg_T *oap)
@@ -1512,7 +1515,7 @@ checkclearop(oparg_T *oap)
 /*
  * Check for operator or Visual active.  Clear active operator.
  *
- * Return TRUE if operator or Visual was active.
+ * Beep and return TRUE if an operator or Visual was active.
  */
     static int
 checkclearopq(oparg_T *oap)
index 176d2823d65f746990ea26fe7f7cf30c806b87b2..b74dda956dad659fdb1b98abc6616cbd8db1c11a 100644 (file)
@@ -3672,7 +3672,7 @@ endfunc
 " Test for ModeChanged pattern
 func Test_mode_changes()
   let g:index = 0
-  let g:mode_seq = ['n', 'i', 'n', 'v', 'V', 'i', 'ix', 'i', 'ic', 'i', 'n', 'no', 'n', 'V', 'v', 's', 'n']
+  let g:mode_seq = ['n', 'i', 'n', 'v', 'V', 'i', 'ix', 'i', 'ic', 'i', 'n', 'no', 'noV', 'n', 'V', 'v', 's', 'n']
   func! TestMode()
     call assert_equal(g:mode_seq[g:index], get(v:event, "old_mode"))
     call assert_equal(g:mode_seq[g:index + 1], get(v:event, "new_mode"))
@@ -3683,7 +3683,7 @@ func Test_mode_changes()
   au ModeChanged * :call TestMode()
   let g:n_to_any = 0
   au ModeChanged n:* let g:n_to_any += 1
-  call feedkeys("i\<esc>vVca\<CR>\<C-X>\<C-L>\<esc>ggdG", 'tnix')
+  call feedkeys("i\<esc>vVca\<CR>\<C-X>\<C-L>\<esc>ggdV\<MouseMove>G", 'tnix')
 
   let g:V_to_v = 0
   au ModeChanged V:v let g:V_to_v += 1
index 5aa2c12cf54cc3d0da3500c431e14c0ed0a91642..e5a6ada0c2f2972ed72b242b7ea7694735afe11e 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1490,
 /**/
     1489,
 /**/