To: vim_dev@googlegroups.com Subject: Patch 8.2.0662 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0662 Problem: Cannot use input() in a channel callback. Solution: Reset vgetc_busy. (closes #6010) Files: src/globals.h, src/ex_getln.c, src/evalfunc.c, src/testdir/test_channel.vim *** ../vim-8.2.0661/src/globals.h 2020-04-23 22:16:49.767270674 +0200 --- src/globals.h 2020-04-29 22:20:04.727903850 +0200 *************** *** 1814,1819 **** --- 1814,1822 ---- EXTERN int did_add_timer INIT(= FALSE); EXTERN int timer_busy INIT(= 0); // when timer is inside vgetc() then > 0 #endif + #ifdef FEAT_EVAL + EXTERN int input_busy INIT(= 0); // when inside get_user_input() then > 0 + #endif #ifdef FEAT_BEVAL_TERM EXTERN int bevalexpr_due_set INIT(= FALSE); *** ../vim-8.2.0661/src/ex_getln.c 2020-04-25 15:53:59.202665286 +0200 --- src/ex_getln.c 2020-04-29 22:22:09.599377535 +0200 *************** *** 4468,4473 **** --- 4468,4475 ---- rettv->v_type = VAR_STRING; rettv->vval.v_string = NULL; + if (input_busy) + return; // this doesn't work recursively. #ifdef NO_CONSOLE_INPUT // While starting up, there is no place to enter text. When running tests *************** *** 4528,4539 **** --- 4530,4547 ---- if (defstr != NULL) { int save_ex_normal_busy = ex_normal_busy; + int save_vgetc_busy = vgetc_busy; + int save_input_busy = input_busy; + input_busy |= vgetc_busy; ex_normal_busy = 0; + vgetc_busy = 0; rettv->vval.v_string = getcmdline_prompt(secret ? NUL : '@', p, get_echo_attr(), xp_type, xp_arg); ex_normal_busy = save_ex_normal_busy; + vgetc_busy = save_vgetc_busy; + input_busy = save_input_busy; } if (inputdialog && rettv->vval.v_string == NULL && argvars[1].v_type != VAR_UNKNOWN *** ../vim-8.2.0661/src/evalfunc.c 2020-04-27 22:47:45.186176148 +0200 --- src/evalfunc.c 2020-04-29 22:22:59.323167937 +0200 *************** *** 2149,2155 **** static void f_eventhandler(typval_T *argvars UNUSED, typval_T *rettv) { ! rettv->vval.v_number = vgetc_busy; } static garray_T redir_execute_ga; --- 2149,2155 ---- static void f_eventhandler(typval_T *argvars UNUSED, typval_T *rettv) { ! rettv->vval.v_number = vgetc_busy || input_busy; } static garray_T redir_execute_ga; *************** *** 2566,2572 **** #ifdef FEAT_TIMERS || timer_busy #endif ! ) typebuf_was_filled = TRUE; } vim_free(keys_esc); --- 2566,2572 ---- #ifdef FEAT_TIMERS || timer_busy #endif ! || input_busy) typebuf_was_filled = TRUE; } vim_free(keys_esc); *************** *** 2887,2893 **** } static type_T * ! ret_f_function(int argcount, type_T **argtypes UNUSED) { if (argcount == 1 && argtypes[0]->tt_type == VAR_STRING) return &t_func_any; --- 2887,2893 ---- } static type_T * ! ret_f_function(int argcount, type_T **argtypes) { if (argcount == 1 && argtypes[0]->tt_type == VAR_STRING) return &t_func_any; *** ../vim-8.2.0661/src/testdir/test_channel.vim 2020-04-26 15:59:51.202952140 +0200 --- src/testdir/test_channel.vim 2020-04-29 22:26:35.118258582 +0200 *************** *** 6,11 **** --- 6,12 ---- source shared.vim source screendump.vim + source view_util.vim let s:python = PythonProg() if s:python == '' *************** *** 2297,2300 **** --- 2298,2317 ---- %bw! endfunc + func ExitCb_cb_with_input(job, status) + call feedkeys(":\echo input('', 'default')\\", 'nx') + call assert_equal('default', Screenline(&lines)) + let g:wait_exit_cb = 0 + endfunc + + func Test_cb_with_input() + let g:wait_exit_cb = 1 + + call job_start('echo "Vim''s test"', + \ {'out_cb': 'ExitCb_cb_with_input'}) + call WaitForAssert({-> assert_equal(0, g:wait_exit_cb)}) + + unlet g:wait_exit_cb + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0661/src/version.c 2020-04-29 22:01:18.160649893 +0200 --- src/version.c 2020-04-29 22:29:46.201453686 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 662, /**/ -- One difference between a man and a machine is that a machine is quiet when well oiled. /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///