mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
vim-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 vim/vim#5974)
65d032c779
This commit is contained in:
@@ -1838,12 +1838,15 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv,
|
|||||||
int opt_type;
|
int opt_type;
|
||||||
long numval;
|
long numval;
|
||||||
char *stringval = NULL;
|
char *stringval = NULL;
|
||||||
|
const char *s = NULL;
|
||||||
|
|
||||||
const char c1 = *p;
|
const char c1 = *p;
|
||||||
*p = NUL;
|
*p = NUL;
|
||||||
|
|
||||||
varnumber_T n = tv_get_number(tv);
|
varnumber_T n = tv_get_number(tv);
|
||||||
const char *s = tv_get_string_chk(tv); // != NULL if number or string.
|
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 != '=') {
|
if (s != NULL && op != NULL && *op != '=') {
|
||||||
opt_type = get_option_value(arg, &numval, (char_u **)&stringval,
|
opt_type = get_option_value(arg, &numval, (char_u **)&stringval,
|
||||||
opt_flags);
|
opt_flags);
|
||||||
@@ -1869,7 +1872,8 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s != NULL) {
|
if (s != NULL || tv->v_type == VAR_BOOL
|
||||||
|
|| tv->v_type == VAR_SPECIAL) {
|
||||||
set_option_value((const char *)arg, n, s, opt_flags);
|
set_option_value((const char *)arg, n, s, opt_flags);
|
||||||
arg_end = (char_u *)p;
|
arg_end = (char_u *)p;
|
||||||
}
|
}
|
||||||
|
@@ -561,3 +561,18 @@ func Test_visualbell()
|
|||||||
set novisualbell
|
set novisualbell
|
||||||
set belloff=all
|
set belloff=all
|
||||||
endfunc
|
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
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user