]> granicus.if.org Git - vim/commitdiff
patch 8.2.1612: Vim9: cannot pass "true" to prop_remove() v8.2.1612
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Sep 2020 18:50:49 +0000 (20:50 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Sep 2020 18:50:49 +0000 (20:50 +0200)
Problem:    Vim9: cannot pass "true" to prop_remove().
Solution:   Use dict_get_bool(). (closes #6853)

src/testdir/test_textprop.vim
src/textprop.c
src/version.c

index 012b3ebf842a8400fcdf00f86ecab79a182c12a3..f7718124b346e83500702537653a06438344966d 100644 (file)
@@ -321,6 +321,15 @@ func Test_prop_remove()
   bwipe!
 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()
   call setline(1, 'xonex xtwoxx')
   normal gg0
index beb9a273d0e1ace2fe1912a04bc559e31646d0e3..c291a295fe4fa31eb177e32dd16ce8dc57e24db9 100644 (file)
@@ -805,11 +805,10 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
     linenr_T   lnum;
     dict_T     *dict;
     buf_T      *buf = curbuf;
-    dictitem_T *di;
-    int                do_all = FALSE;
+    int                do_all;
     int                id = -1;
     int                type_id = -1;
-    int                both = FALSE;
+    int                both;
 
     rettv->vval.v_number = 0;
     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)
        return;
 
-    di = dict_find(dict, (char_u*)"all", -1);
-    if (di != NULL)
-       do_all = dict_get_number(dict, (char_u *)"all");
+    do_all = dict_get_bool(dict, (char_u *)"all", FALSE);
 
     if (dict_find(dict, (char_u *)"id", -1) != NULL)
        id = dict_get_number(dict, (char_u *)"id");
@@ -852,8 +849,8 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
            return;
        type_id = type->pt_id;
     }
-    if (dict_find(dict, (char_u *)"both", -1) != NULL)
-       both = dict_get_number(dict, (char_u *)"both");
+    both = dict_get_bool(dict, (char_u *)"both", FALSE);
+
     if (id == -1 && type_id == -1)
     {
        emsg(_("E968: Need at least one of 'id' or 'type'"));
index bcece94d532b76f7f3d6d86be1dd62d482d9154c..34516ac769b2cff5c72b79f059c80a4537940a83 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1612,
 /**/
     1611,
 /**/