0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.2284: Vim9: cannot set an option to a boolean value

Problem:    Vim9: cannot set an option to a boolean value.
Solution:   Check for VAR_BOOL. (closes #7603)
This commit is contained in:
Bram Moolenaar 2021-01-03 14:47:25 +01:00
parent e68b02a1c4
commit 31a201a04a
3 changed files with 13 additions and 1 deletions

View File

@ -3508,7 +3508,9 @@ set_option_from_tv(char_u *varname, typval_T *varp)
char_u nbuf[NUMBUFLEN];
int error = FALSE;
if (!in_vim9script() || varp->v_type != VAR_STRING)
if (varp->v_type == VAR_BOOL)
numval = (long)varp->vval.v_number;
else if (!in_vim9script() || varp->v_type != VAR_STRING)
numval = (long)tv_get_number_chk(varp, &error);
strval = tv_get_string_buf_chk(varp, nbuf);
if (!error && strval != NULL)

View File

@ -652,11 +652,19 @@ def Test_setbufvar()
&syntax->assert_equal('vim')
setbufvar(bufnr('%'), '&ts', 16)
&ts->assert_equal(16)
setbufvar(bufnr('%'), '&ai', true)
&ai->assert_equal(true)
setbufvar(bufnr('%'), '&ft', 'filetype')
&ft->assert_equal('filetype')
settabwinvar(1, 1, '&syntax', 'vam')
&syntax->assert_equal('vam')
settabwinvar(1, 1, '&ts', 15)
&ts->assert_equal(15)
setlocal ts=8
settabwinvar(1, 1, '&list', true)
&list->assert_equal(true)
setlocal list&
setbufvar('%', 'myvar', 123)
getbufvar('%', 'myvar')->assert_equal(123)

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2284,
/**/
2283,
/**/