mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.1480: Vim9: skip expression in search() gives error
Problem: Vim9: skip expression in search() gives error. Solution: use tv_get_bool() eval_expr_to_bool(). (closes #6729)
This commit is contained in:
@@ -326,7 +326,7 @@ eval_expr_to_bool(typval_T *expr, int *error)
|
|||||||
*error = TRUE;
|
*error = TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
res = (tv_get_number_chk(&rettv, error) != 0);
|
res = (tv_get_bool_chk(&rettv, error) != 0);
|
||||||
clear_tv(&rettv);
|
clear_tv(&rettv);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@ void init_tv(typval_T *varp);
|
|||||||
varnumber_T tv_get_number(typval_T *varp);
|
varnumber_T tv_get_number(typval_T *varp);
|
||||||
varnumber_T tv_get_number_chk(typval_T *varp, int *denote);
|
varnumber_T tv_get_number_chk(typval_T *varp, int *denote);
|
||||||
varnumber_T tv_get_bool(typval_T *varp);
|
varnumber_T tv_get_bool(typval_T *varp);
|
||||||
|
varnumber_T tv_get_bool_chk(typval_T *varp, int *denote);
|
||||||
float_T tv_get_float(typval_T *varp);
|
float_T tv_get_float(typval_T *varp);
|
||||||
char_u *tv_get_string(typval_T *varp);
|
char_u *tv_get_string(typval_T *varp);
|
||||||
char_u *tv_get_string_buf(typval_T *varp, char_u *buf);
|
char_u *tv_get_string_buf(typval_T *varp, char_u *buf);
|
||||||
|
@@ -1379,6 +1379,13 @@ func Test_silent_echo()
|
|||||||
call delete('XTest_silent_echo')
|
call delete('XTest_silent_echo')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
def Test_search()
|
||||||
|
new
|
||||||
|
setline(1, ['foo', 'bar'])
|
||||||
|
let val = 0
|
||||||
|
assert_equal(2, search('bar', 'W', 0, 0, {-> val == 1}))
|
||||||
|
enddef
|
||||||
|
|
||||||
def Fibonacci(n: number): number
|
def Fibonacci(n: number): number
|
||||||
if n < 2
|
if n < 2
|
||||||
return n
|
return n
|
||||||
|
11
src/typval.c
11
src/typval.c
@@ -270,6 +270,17 @@ tv_get_bool(typval_T *varp)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the boolean value of "varp". This is like tv_get_number_chk(),
|
||||||
|
* but in Vim9 script accepts Number and Bool.
|
||||||
|
*/
|
||||||
|
varnumber_T
|
||||||
|
tv_get_bool_chk(typval_T *varp, int *denote)
|
||||||
|
{
|
||||||
|
return tv_get_bool_or_number_chk(varp, denote, TRUE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef FEAT_FLOAT
|
#ifdef FEAT_FLOAT
|
||||||
float_T
|
float_T
|
||||||
tv_get_float(typval_T *varp)
|
tv_get_float(typval_T *varp)
|
||||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1480,
|
||||||
/**/
|
/**/
|
||||||
1479,
|
1479,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user