0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.2285: Vim9: cannot set an option to a false

Problem:    Vim9: cannot set an option to a false.
Solution:   For VAR_BOOL use string "0". (closes #7603)
This commit is contained in:
Bram Moolenaar
2021-01-03 15:55:10 +01:00
parent 31a201a04a
commit b0d8182fa3
3 changed files with 13 additions and 3 deletions

View File

@@ -3509,10 +3509,16 @@ set_option_from_tv(char_u *varname, typval_T *varp)
int error = FALSE;
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);
strval = (char_u *)"0"; // avoid using "false"
}
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)
set_option_value(varname, numval, strval, OPT_LOCAL);
}

View File

@@ -662,6 +662,8 @@ def Test_setbufvar()
settabwinvar(1, 1, '&ts', 15)
&ts->assert_equal(15)
setlocal ts=8
settabwinvar(1, 1, '&list', false)
&list->assert_equal(false)
settabwinvar(1, 1, '&list', true)
&list->assert_equal(true)
setlocal list&

View File

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