]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2285: Vim9: cannot set an option to a false v8.2.2285
authorBram Moolenaar <Bram@vim.org>
Sun, 3 Jan 2021 14:55:10 +0000 (15:55 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 3 Jan 2021 14:55:10 +0000 (15:55 +0100)
Problem:    Vim9: cannot set an option to a false.
Solution:   For VAR_BOOL use string "0". (closes #7603)

src/evalvars.c
src/testdir/test_vim9_builtin.vim
src/version.c

index 42b7ef58d70df82bafc2b6586fbd048eb537b3c0..c6b03e99389f6b08cfd0dcd9b85f384265625a5e 100644 (file)
@@ -3509,10 +3509,16 @@ set_option_from_tv(char_u *varname, typval_T *varp)
     int                error = FALSE;
 
     if (varp->v_type == VAR_BOOL)
+    {
        numval = (long)varp->vval.v_number;
-    else if (!in_vim9script() || varp->v_type != VAR_STRING)
-       numval = (long)tv_get_number_chk(varp, &error);
-    strval = tv_get_string_buf_chk(varp, nbuf);
+       strval = (char_u *)"0";  // avoid using "false"
+    }
+    else
+    {
+       if (!in_vim9script() || varp->v_type != VAR_STRING)
+           numval = (long)tv_get_number_chk(varp, &error);
+       strval = tv_get_string_buf_chk(varp, nbuf);
+    }
     if (!error && strval != NULL)
        set_option_value(varname, numval, strval, OPT_LOCAL);
 }
index 74031d4d095be3760d0d3741138ecf6be65265a4..4eb2d76dfdbb232be58d7cfe66e8b18e9ebfff70 100644 (file)
@@ -662,6 +662,8 @@ def Test_setbufvar()
   settabwinvar(1, 1, '&ts', 15)
   &ts->assert_equal(15)
   setlocal ts=8
+  settabwinvar(1, 1, '&list', false)
+  &list->assert_equal(false)
   settabwinvar(1, 1, '&list', true)
   &list->assert_equal(true)
   setlocal list&
index cf7964ccbce2cf6ec051325df9942383633425b7..ea53d3a72ac68e4c62b07128401e8c4e53b5c7f9 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2285,
 /**/
     2284,
 /**/