# HG changeset patch # User Christian Brabandt # Date 1505422804 -7200 # Node ID 937356f8f8d6c1bf2a8a44a53847f0f84dbbb8b2 # Parent a99b6c31b925ae96ff8f6c1f2b327b38dcc552e7 patch 8.0.1109: timer causes error on exit from Ex mode commit https://github.com/vim/vim/commit/f5291f301e9322545f0621b2157e93050d1d4fb3 Author: Bram Moolenaar Date: Thu Sep 14 22:55:37 2017 +0200 patch 8.0.1109: timer causes error on exit from Ex mode Problem: Timer causes error on exit from Ex mode. (xtal8) Solution: save and restore the ex_pressedreturn flag. (Christian Brabandt, closes #2079) diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1224,6 +1224,7 @@ check_due_timer(void) int save_must_redraw = must_redraw; int save_trylevel = trylevel; int save_did_throw = did_throw; + int save_ex_pressedreturn = get_pressedreturn(); except_T *save_current_exception = current_exception; /* Create a scope for running the timer callback, ignoring most of @@ -1257,6 +1258,7 @@ check_due_timer(void) need_update_screen = TRUE; must_redraw = must_redraw > save_must_redraw ? must_redraw : save_must_redraw; + set_pressedreturn(save_ex_pressedreturn); /* Only fire the timer again if it repeats and stop_timer() wasn't * called while inside the callback (tr_id == -1). */ diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -12418,3 +12418,17 @@ ex_folddo(exarg_T *eap) #endif } #endif + +# if defined(FEAT_TIMERS) || defined(PROTO) + int +get_pressedreturn(void) +{ + return ex_pressedreturn; +} + + void +set_pressedreturn(int val) +{ + ex_pressedreturn = val; +} +#endif diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro --- a/src/proto/ex_docmd.pro +++ b/src/proto/ex_docmd.pro @@ -63,4 +63,6 @@ void dialog_msg(char_u *buff, char *form char_u *get_behave_arg(expand_T *xp, int idx); char_u *get_messages_arg(expand_T *xp, int idx); char_u *get_mapclear_arg(expand_T *xp, int idx); +int get_pressedreturn(void); +void set_pressedreturn(int val); /* vim: set ft=c : */ diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim --- a/src/testdir/test_timers.vim +++ b/src/testdir/test_timers.vim @@ -246,4 +246,15 @@ func Test_peek_and_get_char() call timer_stop(intr) endfunc +func Test_ex_mode() + " Function with an empty line. + func Foo(...) + + endfunc + let timer = timer_start(40, function('g:Foo'), {'repeat':-1}) + " This used to throw error E749. + exe "normal Qsleep 100m\rvi\r" + call timer_stop(timer) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1109, +/**/ 1108, /**/ 1107,