patch 9.1.1795: Vim9: popup_show() may return void
Problem: Vim9: popup_show() may return void
Solution: Modify popup_show() to return -1 for an invalid popup window
id (Yegappan Lakshmanan).
fixes: #18389
closes: #18401
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
7bb733f6bf
commit
773054b976
@ -2652,7 +2652,7 @@ static const funcentry_T global_functions[] =
|
||||
{"popup_settext", 2, 2, FEARG_1, arg2_number_string_or_list,
|
||||
ret_void, PROP_FUNC(f_popup_settext)},
|
||||
{"popup_show", 1, 1, FEARG_1, arg1_number,
|
||||
ret_void, PROP_FUNC(f_popup_show)},
|
||||
ret_number, PROP_FUNC(f_popup_show)},
|
||||
{"pow", 2, 2, FEARG_1, arg2_float_or_nr,
|
||||
ret_float, f_pow},
|
||||
{"prevnonblank", 1, 1, FEARG_1, arg1_lnum,
|
||||
|
||||
@ -2832,6 +2832,9 @@ f_popup_show(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
int id;
|
||||
win_T *wp;
|
||||
|
||||
rettv->v_type = VAR_NUMBER;
|
||||
rettv->vval.v_number = -1;
|
||||
|
||||
if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
|
||||
return;
|
||||
|
||||
@ -2846,6 +2849,8 @@ f_popup_show(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
if (wp->w_popup_flags & POPF_INFO)
|
||||
pum_position_info_popup(wp);
|
||||
#endif
|
||||
|
||||
rettv->vval.v_number = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -1264,7 +1264,7 @@ func Test_popup_hide()
|
||||
|
||||
" no error non-existing window
|
||||
eval 1234234->popup_hide()
|
||||
call popup_show(41234234)
|
||||
call assert_equal(-1, popup_show(41234234))
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
@ -2623,7 +2623,7 @@ func Test_popup_hidden()
|
||||
exe "normal anot used by filter\<Esc>"
|
||||
call assert_equal('not used by filter', getline(1))
|
||||
|
||||
call popup_show(winid)
|
||||
call assert_equal(0, popup_show(winid))
|
||||
call feedkeys('y', "xt")
|
||||
call assert_equal(1, s:cb_res)
|
||||
|
||||
|
||||
@ -3269,6 +3269,7 @@ enddef
|
||||
def Test_popup_show()
|
||||
v9.CheckSourceDefAndScriptFailure(['popup_show("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
|
||||
v9.CheckSourceDefAndScriptFailure(['popup_show(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1'])
|
||||
v9.CheckSourceDefAndScriptSuccess(['assert_equal(-1, popup_show(100))'])
|
||||
enddef
|
||||
|
||||
def Test_prevnonblank()
|
||||
|
||||
@ -729,6 +729,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1795,
|
||||
/**/
|
||||
1794,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user