comparison src/edit.c @ 15377:88b0a490816e

patch 8.1.0696: when test_edit fails 'insertmode' may not be reset commit https://github.com/vim/vim/commit/8ad16da7290190f55f88073d5586dfe133fddf45 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 6 15:29:57 2019 +0100 patch 8.1.0696: when test_edit fails 'insertmode' may not be reset 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)
author Bram Moolenaar <Bram@vim.org>
date Sun, 06 Jan 2019 15:30:06 +0100
parents 6abee072b93c
children 87a0e3c3734c
comparison
equal deleted inserted replaced
15376:e2a7a22c6b53 15377:88b0a490816e
4217 char_u *funcname; 4217 char_u *funcname;
4218 pos_T pos; 4218 pos_T pos;
4219 win_T *curwin_save; 4219 win_T *curwin_save;
4220 buf_T *curbuf_save; 4220 buf_T *curbuf_save;
4221 typval_T rettv; 4221 typval_T rettv;
4222 int save_State = State;
4222 4223
4223 funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu; 4224 funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu;
4224 if (*funcname == NUL) 4225 if (*funcname == NUL)
4225 return; 4226 return;
4226 4227
4270 ins_compl_add_list(matchlist); 4271 ins_compl_add_list(matchlist);
4271 else if (matchdict != NULL) 4272 else if (matchdict != NULL)
4272 ins_compl_add_dict(matchdict); 4273 ins_compl_add_dict(matchdict);
4273 4274
4274 theend: 4275 theend:
4276 // Restore State, it might have been changed.
4277 State = save_State;
4278
4275 if (matchdict != NULL) 4279 if (matchdict != NULL)
4276 dict_unref(matchdict); 4280 dict_unref(matchdict);
4277 if (matchlist != NULL) 4281 if (matchlist != NULL)
4278 list_unref(matchlist); 4282 list_unref(matchlist);
4279 } 4283 }
5547 int col; 5551 int col;
5548 char_u *funcname; 5552 char_u *funcname;
5549 pos_T pos; 5553 pos_T pos;
5550 win_T *curwin_save; 5554 win_T *curwin_save;
5551 buf_T *curbuf_save; 5555 buf_T *curbuf_save;
5556 int save_State = State;
5552 5557
5553 /* Call 'completefunc' or 'omnifunc' and get pattern length as a 5558 /* Call 'completefunc' or 'omnifunc' and get pattern length as a
5554 * string */ 5559 * string */
5555 funcname = ctrl_x_mode == CTRL_X_FUNCTION 5560 funcname = ctrl_x_mode == CTRL_X_FUNCTION
5556 ? curbuf->b_p_cfu : curbuf->b_p_ofu; 5561 ? curbuf->b_p_cfu : curbuf->b_p_ofu;
5570 args[2].v_type = VAR_UNKNOWN; 5575 args[2].v_type = VAR_UNKNOWN;
5571 pos = curwin->w_cursor; 5576 pos = curwin->w_cursor;
5572 curwin_save = curwin; 5577 curwin_save = curwin;
5573 curbuf_save = curbuf; 5578 curbuf_save = curbuf;
5574 col = call_func_retnr(funcname, 2, args); 5579 col = call_func_retnr(funcname, 2, args);
5580
5581 State = save_State;
5575 if (curwin_save != curwin || curbuf_save != curbuf) 5582 if (curwin_save != curwin || curbuf_save != curbuf)
5576 { 5583 {
5577 EMSG(_(e_complwin)); 5584 EMSG(_(e_complwin));
5578 return FAIL; 5585 return FAIL;
5579 } 5586 }
10728 static char_u * 10735 static char_u *
10729 do_insert_char_pre(int c) 10736 do_insert_char_pre(int c)
10730 { 10737 {
10731 char_u *res; 10738 char_u *res;
10732 char_u buf[MB_MAXBYTES + 1]; 10739 char_u buf[MB_MAXBYTES + 1];
10740 int save_State = State;
10733 10741
10734 /* Return quickly when there is nothing to do. */ 10742 /* Return quickly when there is nothing to do. */
10735 if (!has_insertcharpre()) 10743 if (!has_insertcharpre())
10736 return NULL; 10744 return NULL;
10737 10745
10760 } 10768 }
10761 10769
10762 set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */ 10770 set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */
10763 --textlock; 10771 --textlock;
10764 10772
10773 // Restore the State, it may have been changed.
10774 State = save_State;
10775
10765 return res; 10776 return res;
10766 } 10777 }
10767 #endif 10778 #endif
10768 10779
10769 /* 10780 /*