mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 07:48:18 +00:00
vim-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 vim/vim#3768)
8ad16da729
This commit is contained in:
@@ -3520,6 +3520,7 @@ expand_by_function (
|
|||||||
win_T *curwin_save;
|
win_T *curwin_save;
|
||||||
buf_T *curbuf_save;
|
buf_T *curbuf_save;
|
||||||
typval_T rettv;
|
typval_T rettv;
|
||||||
|
const int save_State = State;
|
||||||
|
|
||||||
funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu;
|
funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu;
|
||||||
if (*funcname == NUL)
|
if (*funcname == NUL)
|
||||||
@@ -3565,6 +3566,9 @@ expand_by_function (
|
|||||||
ins_compl_add_dict(matchdict);
|
ins_compl_add_dict(matchdict);
|
||||||
|
|
||||||
theend:
|
theend:
|
||||||
|
// Restore State, it might have been changed.
|
||||||
|
State = save_State;
|
||||||
|
|
||||||
if (matchdict != NULL) {
|
if (matchdict != NULL) {
|
||||||
tv_dict_unref(matchdict);
|
tv_dict_unref(matchdict);
|
||||||
}
|
}
|
||||||
@@ -4676,6 +4680,7 @@ static int ins_complete(int c, bool enable_pum)
|
|||||||
pos_T pos;
|
pos_T pos;
|
||||||
win_T *curwin_save;
|
win_T *curwin_save;
|
||||||
buf_T *curbuf_save;
|
buf_T *curbuf_save;
|
||||||
|
const int save_State = State;
|
||||||
|
|
||||||
/* Call 'completefunc' or 'omnifunc' and get pattern length as a
|
/* Call 'completefunc' or 'omnifunc' and get pattern length as a
|
||||||
* string */
|
* string */
|
||||||
@@ -4694,6 +4699,8 @@ static int ins_complete(int c, bool enable_pum)
|
|||||||
curwin_save = curwin;
|
curwin_save = curwin;
|
||||||
curbuf_save = curbuf;
|
curbuf_save = curbuf;
|
||||||
col = call_func_retnr(funcname, 2, args, FALSE);
|
col = call_func_retnr(funcname, 2, args, FALSE);
|
||||||
|
|
||||||
|
State = save_State;
|
||||||
if (curwin_save != curwin || curbuf_save != curbuf) {
|
if (curwin_save != curwin || curbuf_save != curbuf) {
|
||||||
EMSG(_(e_complwin));
|
EMSG(_(e_complwin));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -8667,6 +8674,7 @@ static colnr_T get_nolist_virtcol(void)
|
|||||||
static char_u *do_insert_char_pre(int c)
|
static char_u *do_insert_char_pre(int c)
|
||||||
{
|
{
|
||||||
char buf[MB_MAXBYTES + 1];
|
char buf[MB_MAXBYTES + 1];
|
||||||
|
const int save_State = State;
|
||||||
|
|
||||||
// Return quickly when there is nothing to do.
|
// Return quickly when there is nothing to do.
|
||||||
if (!has_event(EVENT_INSERTCHARPRE)) {
|
if (!has_event(EVENT_INSERTCHARPRE)) {
|
||||||
@@ -8691,6 +8699,9 @@ static char_u *do_insert_char_pre(int c)
|
|||||||
set_vim_var_string(VV_CHAR, NULL, -1);
|
set_vim_var_string(VV_CHAR, NULL, -1);
|
||||||
textlock--;
|
textlock--;
|
||||||
|
|
||||||
|
// Restore the State, it may have been changed.
|
||||||
|
State = save_State;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -130,6 +130,10 @@ func RunTheTest(test)
|
|||||||
endtry
|
endtry
|
||||||
endif
|
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")
|
if exists("*TearDown")
|
||||||
try
|
try
|
||||||
call TearDown()
|
call TearDown()
|
||||||
|
Reference in New Issue
Block a user