]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.1.0696: when test_edit fails 'insertmode' may not be reset v8.1.0696
authorBram Moolenaar <Bram@vim.org>
Sun, 6 Jan 2019 14:29:57 +0000 (15:29 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 6 Jan 2019 14:29:57 +0000 (15:29 +0100)
Problem:    When test_edit fails 'insertmode' may not be reset and the next
            test may get stuck. (James McCoy)
Solution:   Always reset 'insertmode' after executing a test.  Avoid that an
            InsertCharPre autocommand or a 'complete' function can change the
            state. (closes #3768)

src/edit.c
src/testdir/runtest.vim
src/version.c

index 65f2bb1e7d04a783a13da9486b000d3e1a732fda..d4951d9f34f04691929f52e02861da8ebe641651 100644 (file)
@@ -4219,6 +4219,7 @@ expand_by_function(
     win_T      *curwin_save;
     buf_T      *curbuf_save;
     typval_T   rettv;
+    int                save_State = State;
 
     funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu;
     if (*funcname == NUL)
@@ -4272,6 +4273,9 @@ expand_by_function(
        ins_compl_add_dict(matchdict);
 
 theend:
+    // Restore State, it might have been changed.
+    State = save_State;
+
     if (matchdict != NULL)
        dict_unref(matchdict);
     if (matchlist != NULL)
@@ -5549,6 +5553,7 @@ ins_complete(int c, int enable_pum)
            pos_T       pos;
            win_T       *curwin_save;
            buf_T       *curbuf_save;
+           int         save_State = State;
 
            /* Call 'completefunc' or 'omnifunc' and get pattern length as a
             * string */
@@ -5572,6 +5577,8 @@ ins_complete(int c, int enable_pum)
            curwin_save = curwin;
            curbuf_save = curbuf;
            col = call_func_retnr(funcname, 2, args);
+
+           State = save_State;
            if (curwin_save != curwin || curbuf_save != curbuf)
            {
                EMSG(_(e_complwin));
@@ -10730,6 +10737,7 @@ do_insert_char_pre(int c)
 {
     char_u     *res;
     char_u     buf[MB_MAXBYTES + 1];
+    int                save_State = State;
 
     /* Return quickly when there is nothing to do. */
     if (!has_insertcharpre())
@@ -10762,6 +10770,9 @@ do_insert_char_pre(int c)
     set_vim_var_string(VV_CHAR, NULL, -1);  /* clear v:char */
     --textlock;
 
+    // Restore the State, it may have been changed.
+    State = save_State;
+
     return res;
 }
 #endif
index 89c1e3a5e0e5358deab73ae64b2f0c7f42632e27..a8b43aaed97666292a7dccaabd69e505bfb61420 100644 (file)
@@ -26,7 +26,7 @@
 " It will be called after each Test_ function.
 "
 " When debugging a test it can be useful to add messages to v:errors:
-"      call add(v:errors, "this happened")
+"      call add(v:errors, "this happened")
 
 
 " Without the +eval feature we can't run these tests, bail out.
@@ -149,6 +149,10 @@ func RunTheTest(test)
     endtry
   endif
 
+  " In case 'insertmode' was set and something went wrong, make sure it is
+  " reset to avoid trouble with anything else.
+  set noinsertmode
+
   if exists("*TearDown")
     try
       call TearDown()
index 790c4f7706afa5a6563a891a3f0e41e44bcf11ef..3f6b5ec3b2ed8f7bd8c2222441632dad1b2ed677 100644 (file)
@@ -799,6 +799,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    696,
 /**/
     695,
 /**/