diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-04-24 20:57:01 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-04-24 20:57:01 +0200 |
commit | 65d032c779a43b767497e15e6a32d04a6a8fa65d (patch) | |
tree | 23d8679105c015540703fd4103c910cd5374eebb | |
parent | e71ebb46a252cd1cdfb075e6014c2b13c580bf3f (diff) | |
download | vim-git-65d032c779a43b767497e15e6a32d04a6a8fa65d.tar.gz |
patch 8.2.0629: setting a boolean option to v:false does not workv8.2.0629
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)
-rw-r--r-- | src/evalvars.c | 9 | ||||
-rw-r--r-- | src/testdir/test_options.vim | 14 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 22 insertions, 3 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index 1d0599f5a..7c8b9f7ac 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -1251,13 +1251,15 @@ ex_let_one( 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 @@ ex_let_one( } } } - 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; diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index e03d7e99c..dec82885f 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -899,4 +899,18 @@ func Test_opt_num_op() 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 diff --git a/src/version.c b/src/version.c index 8782b37a7..d22750016 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 629, +/**/ 628, /**/ 627, |