]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0884: mouse shape remains in op-pending mode after failed change v9.0.0884
authorzeertzjq <zeertzjq@outlook.com>
Tue, 15 Nov 2022 13:46:12 +0000 (13:46 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 15 Nov 2022 13:46:12 +0000 (13:46 +0000)
Problem:    Mouse shape remains in op-pending mode after failed change.
Solution:   Reset finish_op and restore it. (closes #11545)

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

index ed8a5d81d98c3ac14897fe898b1ee50344fe84a3..6e51822889596bc598ea5b6ec9964881d107474f 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -1775,8 +1775,14 @@ op_change(oparg_T *oap)
     if (oap->motion_type == MLINE)
        fix_indent();
 
+    // Reset finish_op now, don't want it set inside edit().
+    int save_finish_op = finish_op;
+    finish_op = FALSE;
+
     retval = edit(NUL, FALSE, (linenr_T)1);
 
+    finish_op = save_finish_op;
+
     /*
      * In Visual block mode, handle copying the new text to all lines of the
      * block.
@@ -3438,8 +3444,6 @@ op_function(oparg_T *oap UNUSED)
 {
 #ifdef FEAT_EVAL
     typval_T   argv[2];
-    int                save_virtual_op = virtual_op;
-    int                save_finish_op = finish_op;
     pos_T      orig_start = curbuf->b_op_start;
     pos_T      orig_end = curbuf->b_op_end;
     typval_T   rettv;
@@ -3466,9 +3470,11 @@ op_function(oparg_T *oap UNUSED)
 
        // Reset virtual_op so that 'virtualedit' can be changed in the
        // function.
+       int save_virtual_op = virtual_op;
        virtual_op = MAYBE;
 
        // Reset finish_op so that mode() returns the right value.
+       int save_finish_op = finish_op;
        finish_op = FALSE;
 
        if (call_callback(&opfunc_cb, 0, &rettv, 1, argv) != FAIL)
@@ -4113,8 +4119,6 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
                // before.
                restore_lbr(lbr_saved);
 #endif
-               // Reset finish_op now, don't want it set inside edit().
-               finish_op = FALSE;
                if (op_change(oap))     // will call edit()
                    cap->retval |= CA_COMMAND_BUSY;
                if (restart_edit == 0)
index 909492718bad02fb91fa4ac3534ae307c97e09c8..f7194b6035002f7b198cf0ecd3928c9931d5da04 100644 (file)
@@ -3807,4 +3807,37 @@ func Test_normal_count_out_of_range()
   bwipe!
 endfunc
 
+" Test that mouse shape is restored to Normal mode after failed "c" operation.
+func Test_mouse_shape_after_failed_change()
+  CheckFeature mouseshape
+  CheckCanRunGui
+
+  let lines =<< trim END
+    set mouseshape+=o:busy
+    setlocal nomodifiable
+    let g:mouse_shapes = []
+
+    func SaveMouseShape(timer)
+      let g:mouse_shapes += [getmouseshape()]
+    endfunc
+
+    func SaveAndQuit(timer)
+      call writefile(g:mouse_shapes, 'Xmouseshapes')
+      quit
+    endfunc
+
+    call timer_start(50, {_ -> feedkeys('c')})
+    call timer_start(100, 'SaveMouseShape')
+    call timer_start(150, {_ -> feedkeys('c')})
+    call timer_start(200, 'SaveMouseShape')
+    call timer_start(250, 'SaveAndQuit')
+  END
+  call writefile(lines, 'Xmouseshape.vim', 'D')
+  call RunVim([], [], "-g -S Xmouseshape.vim")
+  sleep 300m
+  call assert_equal(['busy', 'arrow'], readfile('Xmouseshapes'))
+
+  call delete('Xmouseshapes')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 7fae79d38bdf012e07aa21147300879cde9f3442..3ca13a89b0d153e1575d46f9803cc081ca2db72e 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    884,
 /**/
     883,
 /**/