mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.2.0662: cannot use input() in a channel callback
Problem: Cannot use input() in a channel callback. Solution: Reset vgetc_busy. (closes #6010)
This commit is contained in:
@@ -2149,7 +2149,7 @@ f_eval(typval_T *argvars, typval_T *rettv)
|
|||||||
static void
|
static void
|
||||||
f_eventhandler(typval_T *argvars UNUSED, typval_T *rettv)
|
f_eventhandler(typval_T *argvars UNUSED, typval_T *rettv)
|
||||||
{
|
{
|
||||||
rettv->vval.v_number = vgetc_busy;
|
rettv->vval.v_number = vgetc_busy || input_busy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static garray_T redir_execute_ga;
|
static garray_T redir_execute_ga;
|
||||||
@@ -2566,7 +2566,7 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
|
|||||||
#ifdef FEAT_TIMERS
|
#ifdef FEAT_TIMERS
|
||||||
|| timer_busy
|
|| timer_busy
|
||||||
#endif
|
#endif
|
||||||
)
|
|| input_busy)
|
||||||
typebuf_was_filled = TRUE;
|
typebuf_was_filled = TRUE;
|
||||||
}
|
}
|
||||||
vim_free(keys_esc);
|
vim_free(keys_esc);
|
||||||
@@ -2887,7 +2887,7 @@ f_funcref(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static type_T *
|
static type_T *
|
||||||
ret_f_function(int argcount, type_T **argtypes UNUSED)
|
ret_f_function(int argcount, type_T **argtypes)
|
||||||
{
|
{
|
||||||
if (argcount == 1 && argtypes[0]->tt_type == VAR_STRING)
|
if (argcount == 1 && argtypes[0]->tt_type == VAR_STRING)
|
||||||
return &t_func_any;
|
return &t_func_any;
|
||||||
|
@@ -4468,6 +4468,8 @@ get_user_input(
|
|||||||
|
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
rettv->vval.v_string = NULL;
|
rettv->vval.v_string = NULL;
|
||||||
|
if (input_busy)
|
||||||
|
return; // this doesn't work recursively.
|
||||||
|
|
||||||
#ifdef NO_CONSOLE_INPUT
|
#ifdef NO_CONSOLE_INPUT
|
||||||
// While starting up, there is no place to enter text. When running tests
|
// While starting up, there is no place to enter text. When running tests
|
||||||
@@ -4528,12 +4530,18 @@ get_user_input(
|
|||||||
if (defstr != NULL)
|
if (defstr != NULL)
|
||||||
{
|
{
|
||||||
int save_ex_normal_busy = ex_normal_busy;
|
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;
|
ex_normal_busy = 0;
|
||||||
|
vgetc_busy = 0;
|
||||||
rettv->vval.v_string =
|
rettv->vval.v_string =
|
||||||
getcmdline_prompt(secret ? NUL : '@', p, get_echo_attr(),
|
getcmdline_prompt(secret ? NUL : '@', p, get_echo_attr(),
|
||||||
xp_type, xp_arg);
|
xp_type, xp_arg);
|
||||||
ex_normal_busy = save_ex_normal_busy;
|
ex_normal_busy = save_ex_normal_busy;
|
||||||
|
vgetc_busy = save_vgetc_busy;
|
||||||
|
input_busy = save_input_busy;
|
||||||
}
|
}
|
||||||
if (inputdialog && rettv->vval.v_string == NULL
|
if (inputdialog && rettv->vval.v_string == NULL
|
||||||
&& argvars[1].v_type != VAR_UNKNOWN
|
&& argvars[1].v_type != VAR_UNKNOWN
|
||||||
|
@@ -1814,6 +1814,9 @@ EXTERN int in_free_unref_items INIT(= FALSE);
|
|||||||
EXTERN int did_add_timer INIT(= FALSE);
|
EXTERN int did_add_timer INIT(= FALSE);
|
||||||
EXTERN int timer_busy INIT(= 0); // when timer is inside vgetc() then > 0
|
EXTERN int timer_busy INIT(= 0); // when timer is inside vgetc() then > 0
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
|
EXTERN int input_busy INIT(= 0); // when inside get_user_input() then > 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_BEVAL_TERM
|
#ifdef FEAT_BEVAL_TERM
|
||||||
EXTERN int bevalexpr_due_set INIT(= FALSE);
|
EXTERN int bevalexpr_due_set INIT(= FALSE);
|
||||||
|
@@ -6,6 +6,7 @@ CheckFeature channel
|
|||||||
|
|
||||||
source shared.vim
|
source shared.vim
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
|
source view_util.vim
|
||||||
|
|
||||||
let s:python = PythonProg()
|
let s:python = PythonProg()
|
||||||
if s:python == ''
|
if s:python == ''
|
||||||
@@ -2297,4 +2298,20 @@ func Test_job_with_list_args()
|
|||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func ExitCb_cb_with_input(job, status)
|
||||||
|
call feedkeys(":\<C-u>echo input('', 'default')\<CR>\<CR>", '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: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
662,
|
||||||
/**/
|
/**/
|
||||||
661,
|
661,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user