]> granicus.if.org Git - vim/commitdiff
patch 8.2.1485: Vim9: readdirex() expression doesn't accept bool v8.2.1485
authorBram Moolenaar <Bram@vim.org>
Wed, 19 Aug 2020 11:55:01 +0000 (13:55 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 19 Aug 2020 11:55:01 +0000 (13:55 +0200)
Problem:    Vim9: readdirex() expression doesn't accept bool.
Solution:   Accept both -1 and bool. (closes #6737)

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

index a1e281b0eefd3ecbb5d8d3930b5426f9c1e37fc5..d4592eba3155273ca180792cb76e0385889cd132 100644 (file)
@@ -1493,6 +1493,12 @@ readdirex_checkitem(void *context, void *item)
     if (eval_expr_typval(expr, argv, 1, &rettv) == FAIL)
        goto theend;
 
+    // We want to use -1, but also true/false should be allowed.
+    if (rettv.v_type == VAR_SPECIAL || rettv.v_type == VAR_BOOL)
+    {
+       rettv.v_type = VAR_NUMBER;
+       rettv.vval.v_number = rettv.vval.v_number == VVAL_TRUE;
+    }
     retval = tv_get_number_chk(&rettv, &error);
     if (error)
        retval = -1;
index 79fd80ae1863e85db271ef951ed22eb729b2aeee..751cd6d6020daf7a0f05991a3b963d415dca2d4e 100644 (file)
@@ -1386,6 +1386,10 @@ def Test_search()
   assert_equal(2, search('bar', 'W', 0, 0, {-> val == 1}))
 enddef
 
+def Test_readdirex()
+   eval expand('.')->readdirex({e -> e.name[0] !=# '.'})
+enddef
+
 def Fibonacci(n: number): number
   if n < 2
     return n
index 80f464a36d9248543adc435e65088ea5ef040bd9..3c1eb1cf5ceb020c5dbd300b547f7bbf31edbaa0 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1485,
 /**/
     1484,
 /**/