]> granicus.if.org Git - vim/commitdiff
patch 8.2.1614: Vim9: cannot pass "true" to searchcount() v8.2.1614
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Sep 2020 19:21:16 +0000 (21:21 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Sep 2020 19:21:16 +0000 (21:21 +0200)
Problem:    Vim9: cannot pass "true" to searchcount().
Solution:   Use tv_get_bool_chk(). (closes #6854)

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

index 7391ab0fbf811837355686b18398f3c1cc2dddd8..c1da58b461ab641ae40a8c7619da4dce5c516fa1 100644 (file)
@@ -4062,7 +4062,7 @@ f_searchcount(typval_T *argvars, typval_T *rettv)
     char_u             *pattern = NULL;
     int                        maxcount = SEARCH_STAT_DEF_MAX_COUNT;
     long               timeout = SEARCH_STAT_DEF_TIMEOUT;
-    int                        recompute = TRUE;
+    int                        recompute = FALSE;
     searchstat_T       stat;
 
     if (rettv_dict_alloc(rettv) == FAIL)
@@ -4098,13 +4098,7 @@ f_searchcount(typval_T *argvars, typval_T *rettv)
            if (error)
                return;
        }
-       di = dict_find(dict, (char_u *)"recompute", -1);
-       if (di != NULL)
-       {
-           recompute = tv_get_number_chk(&di->di_tv, &error);
-           if (error)
-               return;
-       }
+       recompute = dict_get_bool(dict, (char_u *)"recompute", recompute);
        di = dict_find(dict, (char_u *)"pattern", -1);
        if (di != NULL)
        {
index b3b6b32251de6e00d007ddb41b8f2ec4a44e56fd..6aa9f365aff67bb8f95f3a8d151b9d565635dc9f 100644 (file)
@@ -1533,6 +1533,20 @@ def Test_nr2char()
   assert_equal('a', nr2char(97, true))
 enddef
 
+def Test_searchcount()
+  new
+  setline(1, "foo bar")
+  :/foo
+  assert_equal(#{
+      exact_match: 1,
+      current: 1,
+      total: 1,
+      maxcount: 99,
+      incomplete: 0,
+    }, searchcount(#{recompute: true}))
+  bwipe!
+enddef
+
 def Fibonacci(n: number): number
   if n < 2
     return n
index 4b9100cc456ee45224a37c240c6372e00256d36f..750e2874aef517d912ff4f7b487034e52af74b95 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1614,
 /**/
     1613,
 /**/