changeset 22129:003f51ef2e5c v8.2.1614

patch 8.2.1614: Vim9: cannot pass "true" to searchcount() Commit: https://github.com/vim/vim/commit/597aaac9d2b090e0eb738ab4e2afd454b7b92393 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 5 21:21:16 2020 +0200 patch 8.2.1614: Vim9: cannot pass "true" to searchcount() Problem: Vim9: cannot pass "true" to searchcount(). Solution: Use tv_get_bool_chk(). (closes https://github.com/vim/vim/issues/6854)
author Bram Moolenaar <Bram@vim.org>
date Sat, 05 Sep 2020 21:30:04 +0200
parents cee113d6f754
children 2b7c85de5c77
files src/search.c src/testdir/test_vim9_func.vim src/version.c
diffstat 3 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/search.c
+++ b/src/search.c
@@ -4062,7 +4062,7 @@ f_searchcount(typval_T *argvars, typval_
     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_
 	    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)
 	{
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -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
--- 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 */
 /**/
+    1614,
+/**/
     1613,
 /**/
     1612,