Skip to content

Commit a5a40c5

Browse files
committed
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)
1 parent ed6a430 commit a5a40c5

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/testdir/test_textprop.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,15 @@ func Test_prop_remove()
321321
bwipe!
322322
endfunc
323323

324+
def Test_prop_remove_vim9()
325+
new
326+
call AddPropTypes()
327+
call SetupPropsInFirstLine()
328+
call assert_equal(1, prop_remove({'type': 'three', 'id': 13, 'both': true, 'all': true}))
329+
call DeletePropTypes()
330+
bwipe!
331+
enddef
332+
324333
func SetupOneLine()
325334
call setline(1, 'xonex xtwoxx')
326335
normal gg0

src/textprop.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -805,11 +805,10 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
805805
linenr_T lnum;
806806
dict_T *dict;
807807
buf_T *buf = curbuf;
808-
dictitem_T *di;
809-
int do_all = FALSE;
808+
int do_all;
810809
int id = -1;
811810
int type_id = -1;
812-
int both = FALSE;
811+
int both;
813812

814813
rettv->vval.v_number = 0;
815814
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)
837836
if (buf->b_ml.ml_mfp == NULL)
838837
return;
839838

840-
di = dict_find(dict, (char_u*)"all", -1);
841-
if (di != NULL)
842-
do_all = dict_get_number(dict, (char_u *)"all");
839+
do_all = dict_get_bool(dict, (char_u *)"all", FALSE);
843840

844841
if (dict_find(dict, (char_u *)"id", -1) != NULL)
845842
id = dict_get_number(dict, (char_u *)"id");
@@ -852,8 +849,8 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
852849
return;
853850
type_id = type->pt_id;
854851
}
855-
if (dict_find(dict, (char_u *)"both", -1) != NULL)
856-
both = dict_get_number(dict, (char_u *)"both");
852+
both = dict_get_bool(dict, (char_u *)"both", FALSE);
853+
857854
if (id == -1 && type_id == -1)
858855
{
859856
emsg(_("E968: Need at least one of 'id' or 'type'"));

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1612,
757759
/**/
758760
1611,
759761
/**/

0 commit comments

Comments
 (0)