Mercurial > vim
diff src/ex_cmds2.c @ 13892:eadecbe4e390 v8.0.1817
patch 8.0.1817: a timer may change v:count unexpectedly
commit https://github.com/vim/vim/commit/b0f42ba60d9e6d101d103421ba0c351811615c15
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 12 15:38:26 2018 +0200
patch 8.0.1817: a timer may change v:count unexpectedly
Problem: A timer may change v:count unexpectedly.
Solution: Save and restore v:count and similar variables when a timer
callback is invoked. (closes #2897)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 12 May 2018 15:45:05 +0200 |
parents | a590029f16a0 |
children | 4cb334816bb1 |
line wrap: on
line diff
--- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1336,6 +1336,8 @@ check_due_timer(void) this_due = proftime_time_left(&timer->tr_due, &now); if (this_due <= 1) { + /* Save and restore a lot of flags, because the timer fires while + * waiting for a character, which might be halfway a command. */ int save_timer_busy = timer_busy; int save_vgetc_busy = vgetc_busy; int save_did_emsg = did_emsg; @@ -1345,6 +1347,7 @@ check_due_timer(void) int save_did_throw = did_throw; int save_ex_pressedreturn = get_pressedreturn(); except_T *save_current_exception = current_exception; + vimvars_save_T vvsave; /* Create a scope for running the timer callback, ignoring most of * the current scope, such as being inside a try/catch. */ @@ -1357,6 +1360,7 @@ check_due_timer(void) trylevel = 0; did_throw = FALSE; current_exception = NULL; + save_vimvars(&vvsave); timer->tr_firing = TRUE; timer_callback(timer); @@ -1373,6 +1377,7 @@ check_due_timer(void) trylevel = save_trylevel; did_throw = save_did_throw; current_exception = save_current_exception; + restore_vimvars(&vvsave); if (must_redraw != 0) need_update_screen = TRUE; must_redraw = must_redraw > save_must_redraw