aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilly Su <g4691821@gmail.com>2020-04-29 15:49:27 +0800
committerBilly Su <g4691821@gmail.com>2020-06-06 23:25:07 +0800
commit22f6da9514eeebbb7f2344b1b0179b170b1fc9d8 (patch)
tree7f85b4eb417f328163685b4326b300f3c98c9c94
parent1805fb469a39d998f9bef0415999aa835d051044 (diff)
downloadrneovim-22f6da9514eeebbb7f2344b1b0179b170b1fc9d8.tar.gz
rneovim-22f6da9514eeebbb7f2344b1b0179b170b1fc9d8.tar.bz2
rneovim-22f6da9514eeebbb7f2344b1b0179b170b1fc9d8.zip
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) https://github.com/vim/vim/commit/65d032c779a43b767497e15e6a32d04a6a8fa65d
-rw-r--r--src/nvim/eval.c8
-rw-r--r--src/nvim/testdir/test_options.vim15
2 files changed, 21 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 250201c3fe..66cd0e09c6 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1838,12 +1838,15 @@ static char_u *ex_let_one(char_u *arg, typval_T *const tv,
int opt_type;
long numval;
char *stringval = NULL;
+ const char *s = NULL;
const char c1 = *p;
*p = NUL;
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 != '=') {
opt_type = get_option_value(arg, &numval, (char_u **)&stringval,
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);
arg_end = (char_u *)p;
}
diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim
index 400af33c58..04a5c62f66 100644
--- a/src/nvim/testdir/test_options.vim
+++ b/src/nvim/testdir/test_options.vim
@@ -561,3 +561,18 @@ func Test_visualbell()
set novisualbell
set belloff=all
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
+