Skip to content

Commit 597aaac

Browse files
committed
patch 8.2.1614: Vim9: cannot pass "true" to searchcount()
Problem: Vim9: cannot pass "true" to searchcount(). Solution: Use tv_get_bool_chk(). (closes #6854)
1 parent fa2e38d commit 597aaac

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

src/search.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4062,7 +4062,7 @@ f_searchcount(typval_T *argvars, typval_T *rettv)
40624062
char_u *pattern = NULL;
40634063
int maxcount = SEARCH_STAT_DEF_MAX_COUNT;
40644064
long timeout = SEARCH_STAT_DEF_TIMEOUT;
4065-
int recompute = TRUE;
4065+
int recompute = FALSE;
40664066
searchstat_T stat;
40674067

40684068
if (rettv_dict_alloc(rettv) == FAIL)
@@ -4098,13 +4098,7 @@ f_searchcount(typval_T *argvars, typval_T *rettv)
40984098
if (error)
40994099
return;
41004100
}
4101-
di = dict_find(dict, (char_u *)"recompute", -1);
4102-
if (di != NULL)
4103-
{
4104-
recompute = tv_get_number_chk(&di->di_tv, &error);
4105-
if (error)
4106-
return;
4107-
}
4101+
recompute = dict_get_bool(dict, (char_u *)"recompute", recompute);
41084102
di = dict_find(dict, (char_u *)"pattern", -1);
41094103
if (di != NULL)
41104104
{

src/testdir/test_vim9_func.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,20 @@ def Test_nr2char()
15331533
assert_equal('a', nr2char(97, true))
15341534
enddef
15351535

1536+
def Test_searchcount()
1537+
new
1538+
setline(1, "foo bar")
1539+
:/foo
1540+
assert_equal(#{
1541+
exact_match: 1,
1542+
current: 1,
1543+
total: 1,
1544+
maxcount: 99,
1545+
incomplete: 0,
1546+
}, searchcount(#{recompute: true}))
1547+
bwipe!
1548+
enddef
1549+
15361550
def Fibonacci(n: number): number
15371551
if n < 2
15381552
return n

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1614,
757759
/**/
758760
1613,
759761
/**/

0 commit comments

Comments
 (0)