summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/evalfunc.c2
-rw-r--r--src/ex_cmds2.c7
-rw-r--r--src/globals.h1
-rw-r--r--src/testdir/test_timers.vim16
-rw-r--r--src/version.c2
5 files changed, 27 insertions, 1 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 7c781d8b9..581ad7b5b 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3191,7 +3191,7 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE),
insert ? 0 : typebuf.tb_len, !typed, FALSE);
vim_free(keys_esc);
- if (vgetc_busy)
+ if (vgetc_busy || timer_busy)
typebuf_was_filled = TRUE;
if (execute)
{
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 225225a78..33ad924d2 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -1209,11 +1209,18 @@ check_due_timer(void)
this_due = GET_TIMEDIFF(timer, now);
if (this_due <= 1)
{
+ int save_timer_busy = timer_busy;
+ int save_vgetc_busy = vgetc_busy;
+
+ timer_busy = timer_busy > 0 || vgetc_busy > 0;
+ vgetc_busy = 0;
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;
/* 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/globals.h b/src/globals.h
index 56df6d508..7cf928c16 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1659,6 +1659,7 @@ EXTERN int in_free_unref_items INIT(= FALSE);
#ifdef FEAT_TIMERS
EXTERN int did_add_timer INIT(= FALSE);
+EXTERN int timer_busy INIT(= 0); /* when timer is inside vgetc() then > 0 */
#endif
#ifdef FEAT_EVAL
diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim
index ebc666580..fdb74e795 100644
--- a/src/testdir/test_timers.vim
+++ b/src/testdir/test_timers.vim
@@ -172,5 +172,21 @@ func Test_stop_all_in_callback()
call assert_equal(0, len(info))
endfunc
+func FeedkeysCb(timer)
+ call feedkeys("hello\<CR>", 'nt')
+endfunc
+
+func InputCb(timer)
+ call timer_start(10, 'FeedkeysCb')
+ let g:val = input('?')
+ call Resume()
+endfunc
+
+func Test_input_in_timer()
+ let g:val = ''
+ call timer_start(10, 'InputCb')
+ call Standby(1000)
+ call assert_equal('hello', g:val)
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index d1c6119a1..d9fef0afd 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 670,
+/**/
669,
/**/
668,