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,
}
}
}
- 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;
set shiftwidth&
endfunc
+" Test for setting option values using v:false and v:true
+func Test_opt_boolean()
+ set number&
+ set number
+ call assert_equal(1, &nu)
+ set nonu
+ call assert_equal(0, &nu)
+ let &nu = v:true
+ call assert_equal(1, &nu)
+ let &nu = v:false
+ call assert_equal(0, &nu)
+ set number&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab