]> granicus.if.org Git - vim/commitdiff
patch 8.2.1602: Vim9: cannot use 'true" with getbufinfo() v8.2.1602
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Sep 2020 15:37:07 +0000 (17:37 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Sep 2020 15:37:07 +0000 (17:37 +0200)
Problem:    Vim9: cannot use 'true" with getbufinfo().
Solution:   Use dict_get_bool(). (closes #6873)

src/evalbuffer.c
src/testdir/test_vim9_func.vim
src/version.c

index 4ca68c8bb791d052ef92648c52fe6588b411bd49..34155b9cbbbb77a919d2e48bbad6c595dc421efc 100644 (file)
@@ -624,21 +624,11 @@ f_getbufinfo(typval_T *argvars, typval_T *rettv)
 
        if (sel_d != NULL)
        {
-           dictitem_T  *di;
-
            filtered = TRUE;
-
-           di = dict_find(sel_d, (char_u *)"buflisted", -1);
-           if (di != NULL && tv_get_number(&di->di_tv))
-               sel_buflisted = TRUE;
-
-           di = dict_find(sel_d, (char_u *)"bufloaded", -1);
-           if (di != NULL && tv_get_number(&di->di_tv))
-               sel_bufloaded = TRUE;
-
-           di = dict_find(sel_d, (char_u *)"bufmodified", -1);
-           if (di != NULL && tv_get_number(&di->di_tv))
-               sel_bufmodified = TRUE;
+           sel_buflisted = dict_get_bool(sel_d, (char_u *)"buflisted", FALSE);
+           sel_bufloaded = dict_get_bool(sel_d, (char_u *)"bufloaded", FALSE);
+           sel_bufmodified = dict_get_bool(sel_d, (char_u *)"bufmodified",
+                                                                       FALSE);
        }
     }
     else if (argvars[0].v_type != VAR_UNKNOWN)
index 7cc323c1e2b0f4f06b6fc6490a768454f4b97acf..7303db997ddac342759e5bfbd7be42959dcf6809 100644 (file)
@@ -1493,9 +1493,16 @@ def Test_bufname()
   close
 enddef
 
-def Test_gebufinfo()
+def Test_getbufinfo()
   let bufinfo = getbufinfo(bufnr())
   assert_equal(bufinfo, getbufinfo('%'))
+
+  edit Xtestfile1
+  hide edit Xtestfile2
+  hide enew
+  getbufinfo(#{bufloaded: true, buflisted: true, bufmodified: false})
+      ->len()->assert_equal(3)
+  bwipe Xtestfile1 Xtestfile2
 enddef
 
 def Fibonacci(n: number): number
index ab9c0c41d8ddb6b66c6a81c3626dcc40755c1d43..9a58f113c1592869829c6452d2680548cdc6e675 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1602,
 /**/
     1601,
 /**/