patch 8.2.0629: setting a boolean option to v:false does not work
Problem: Setting a boolean option to v:false does not work.
Solution: Do not use the string representation of the value. (Christian
Brabandt, closes #5974)
diff --git a/src/evalvars.c b/src/evalvars.c
index 1d0599f..7c8b9f7 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -1251,13 +1251,15 @@
int opt_type;
long numval;
char_u *stringval = NULL;
- char_u *s;
+ char_u *s = NULL;
c1 = *p;
*p = NUL;
n = (long)tv_get_number(tv);
- s = tv_get_string_chk(tv); // != NULL if number or string
+ // avoid setting a string option to the text "v:false" or similar.
+ if (tv->v_type != VAR_BOOL && tv->v_type != VAR_SPECIAL)
+ s = tv_get_string_chk(tv); // != NULL if number or string
if (s != NULL && op != NULL && *op != '=')
{
opt_type = get_option_value(arg, &numval,
@@ -1289,7 +1291,8 @@
}
}
}
- if (s != NULL)
+ if (s != NULL || tv->v_type == VAR_BOOL
+ || tv->v_type == VAR_SPECIAL)
{
set_option_value(arg, n, s, opt_flags);
arg_end = p;