1
0
forked from aniani/vim

patch 8.2.1612: Vim9: cannot pass "true" to prop_remove()

Problem:    Vim9: cannot pass "true" to prop_remove().
Solution:   Use dict_get_bool(). (closes #6853)
This commit is contained in:
Bram Moolenaar
2020-09-05 20:50:49 +02:00
parent ed6a430fae
commit a5a40c5696
3 changed files with 16 additions and 8 deletions

View File

@@ -321,6 +321,15 @@ func Test_prop_remove()
bwipe! bwipe!
endfunc endfunc
def Test_prop_remove_vim9()
new
call AddPropTypes()
call SetupPropsInFirstLine()
call assert_equal(1, prop_remove({'type': 'three', 'id': 13, 'both': true, 'all': true}))
call DeletePropTypes()
bwipe!
enddef
func SetupOneLine() func SetupOneLine()
call setline(1, 'xonex xtwoxx') call setline(1, 'xonex xtwoxx')
normal gg0 normal gg0

View File

@@ -805,11 +805,10 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
linenr_T lnum; linenr_T lnum;
dict_T *dict; dict_T *dict;
buf_T *buf = curbuf; buf_T *buf = curbuf;
dictitem_T *di; int do_all;
int do_all = FALSE;
int id = -1; int id = -1;
int type_id = -1; int type_id = -1;
int both = FALSE; int both;
rettv->vval.v_number = 0; rettv->vval.v_number = 0;
if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL) if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL)
@@ -837,9 +836,7 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
if (buf->b_ml.ml_mfp == NULL) if (buf->b_ml.ml_mfp == NULL)
return; return;
di = dict_find(dict, (char_u*)"all", -1); do_all = dict_get_bool(dict, (char_u *)"all", FALSE);
if (di != NULL)
do_all = dict_get_number(dict, (char_u *)"all");
if (dict_find(dict, (char_u *)"id", -1) != NULL) if (dict_find(dict, (char_u *)"id", -1) != NULL)
id = dict_get_number(dict, (char_u *)"id"); id = dict_get_number(dict, (char_u *)"id");
@@ -852,8 +849,8 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
return; return;
type_id = type->pt_id; type_id = type->pt_id;
} }
if (dict_find(dict, (char_u *)"both", -1) != NULL) both = dict_get_bool(dict, (char_u *)"both", FALSE);
both = dict_get_number(dict, (char_u *)"both");
if (id == -1 && type_id == -1) if (id == -1 && type_id == -1)
{ {
emsg(_("E968: Need at least one of 'id' or 'type'")); emsg(_("E968: Need at least one of 'id' or 'type'"));

View File

@@ -754,6 +754,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 */
/**/
1612,
/**/ /**/
1611, 1611,
/**/ /**/