changeset 22105:bae2a3fa141f v8.2.1602

patch 8.2.1602: Vim9: cannot use 'true" with getbufinfo() Commit: https://github.com/vim/vim/commit/036c2cf719e3de445779a275514030be66e26883 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 5 17:37:07 2020 +0200 patch 8.2.1602: Vim9: cannot use 'true" with getbufinfo() Problem: Vim9: cannot use 'true" with getbufinfo(). Solution: Use dict_get_bool(). (closes https://github.com/vim/vim/issues/6873)
author Bram Moolenaar <Bram@vim.org>
date Sat, 05 Sep 2020 17:45:04 +0200
parents c3f27d28745a
children fbcfa658f056
files src/evalbuffer.c src/testdir/test_vim9_func.vim src/version.c
diffstat 3 files changed, 14 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalbuffer.c
+++ b/src/evalbuffer.c
@@ -624,21 +624,11 @@ f_getbufinfo(typval_T *argvars, typval_T
 
 	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)
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1602,
+/**/
     1601,
 /**/
     1600,