Patch 8.0.0670
Problem: Can't use input() in a timer callback. (Cosmin Popescu)
Solution: Reset vgetc_busy and set timer_busy. (Ozaki Kiichi, closes #1790,
closes #1129)
Files: src/evalfunc.c, src/ex_cmds2.c, src/globals.h,
src/testdir/test_timers.vim
*** ../vim-8.0.0669/src/evalfunc.c 2017-06-22 22:00:46.414155699 +0200
--- src/evalfunc.c 2017-06-24 15:57:10.094794947 +0200
***************
*** 3191,3197 ****
ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE),
insert ? 0 : typebuf.tb_len, !typed, FALSE);
vim_free(keys_esc);
! if (vgetc_busy)
typebuf_was_filled = TRUE;
if (execute)
{
--- 3191,3197 ----
ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE),
insert ? 0 : typebuf.tb_len, !typed, FALSE);
vim_free(keys_esc);
! if (vgetc_busy || timer_busy)
typebuf_was_filled = TRUE;
if (execute)
{
*** ../vim-8.0.0669/src/ex_cmds2.c 2017-06-04 17:47:38.225528115 +0200
--- src/ex_cmds2.c 2017-06-24 15:50:30.905963239 +0200
***************
*** 1209,1219 ****
--- 1209,1226 ----
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). */
*** ../vim-8.0.0669/src/globals.h 2017-06-04 17:47:38.225528115 +0200
--- src/globals.h 2017-06-24 15:50:30.905963239 +0200
***************
*** 1659,1664 ****
--- 1659,1665 ----
#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
*** ../vim-8.0.0669/src/testdir/test_timers.vim 2016-09-10 13:40:34.000000000
+0200
--- src/testdir/test_timers.vim 2017-06-24 15:49:16.666552788 +0200
***************
*** 172,176 ****
--- 172,192 ----
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
*** ../vim-8.0.0669/src/version.c 2017-06-24 15:39:03.587409087 +0200
--- src/version.c 2017-06-24 16:02:20.912329966 +0200
***************
*** 766,767 ****
--- 766,769 ----
{ /* Add new patch number below this line */
+ /**/
+ 670,
/**/
--
hundred-and-one symptoms of being an internet addict:
82. AT&T names you Customer of the Month for the third consecutive time.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.