summaryrefslogtreecommitdiff
path: root/src/ex_cmds2.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-09-06 23:40:10 +0200
committerBram Moolenaar <Bram@vim.org>2017-09-06 23:40:10 +0200
commite723c42836d971180d1bf9f98916966c5543fff1 (patch)
treeeced5c296dc3ea756078cb48cfdfe95f3f5d0446 /src/ex_cmds2.c
parent2e49b6b20c3d7229edf41ac03931ce32ce0f7bd8 (diff)
downloadvim-git-e723c42836d971180d1bf9f98916966c5543fff1.tar.gz
patch 8.0.1067: try/catch in timer does not prevent it from being stoppedv8.0.1067
Problem: Using try/catch in timer does not prevent it from being stopped. Solution: Reset the exception context and use did_emsg instead of called_emsg.
Diffstat (limited to 'src/ex_cmds2.c')
-rw-r--r--src/ex_cmds2.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 18930a6cf..710a2789e 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -1219,30 +1219,40 @@ check_due_timer(void)
{
int save_timer_busy = timer_busy;
int save_vgetc_busy = vgetc_busy;
- int did_emsg_save = did_emsg;
- int called_emsg_save = called_emsg;
- int did_throw_save = did_throw;
+ int save_did_emsg = did_emsg;
+ int save_called_emsg = called_emsg;
int save_must_redraw = must_redraw;
+ int save_trylevel = trylevel;
+ int save_did_throw = did_throw;
+ except_T *save_current_exception = current_exception;
+ /* Create a scope for running the timer callback, ignoring most of
+ * the current scope, such as being inside a try/catch. */
timer_busy = timer_busy > 0 || vgetc_busy > 0;
vgetc_busy = 0;
called_emsg = FALSE;
+ did_emsg = FALSE;
+ did_uncaught_emsg = FALSE;
must_redraw = 0;
+ trylevel = 0;
+ did_throw = FALSE;
+ current_exception = NULL;
+
timer->tr_firing = TRUE;
timer_callback(timer);
timer->tr_firing = FALSE;
+
timer_next = timer->tr_next;
did_one = TRUE;
timer_busy = save_timer_busy;
vgetc_busy = save_vgetc_busy;
- if (called_emsg)
- {
+ if (did_uncaught_emsg)
++timer->tr_emsg_count;
- if (!did_throw_save && did_throw && current_exception != NULL)
- discard_current_exception();
- }
- did_emsg = did_emsg_save;
- called_emsg = called_emsg_save;
+ did_emsg = save_did_emsg;
+ called_emsg = save_called_emsg;
+ trylevel = save_trylevel;
+ did_throw = save_did_throw;
+ current_exception = save_current_exception;
if (must_redraw != 0)
need_update_screen = TRUE;
must_redraw = must_redraw > save_must_redraw