To: vim_dev@googlegroups.com Subject: Patch 8.2.0629 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.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) Files: src/evalvars.c, src/testdir/test_options.vim *** ../vim-8.2.0628/src/evalvars.c 2020-04-20 17:46:10.588551933 +0200 --- src/evalvars.c 2020-04-24 20:36:39.769023442 +0200 *************** *** 1251,1263 **** int opt_type; long numval; char_u *stringval = NULL; ! char_u *s; c1 = *p; *p = NUL; n = (long)tv_get_number(tv); ! s = tv_get_string_chk(tv); // != NULL if number or string if (s != NULL && op != NULL && *op != '=') { opt_type = get_option_value(arg, &numval, --- 1251,1265 ---- int opt_type; long numval; char_u *stringval = NULL; ! char_u *s = NULL; c1 = *p; *p = NUL; n = (long)tv_get_number(tv); ! // 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,1295 **** } } } ! if (s != NULL) { set_option_value(arg, n, s, opt_flags); arg_end = p; --- 1291,1298 ---- } } } ! if (s != NULL || tv->v_type == VAR_BOOL ! || tv->v_type == VAR_SPECIAL) { set_option_value(arg, n, s, opt_flags); arg_end = p; *** ../vim-8.2.0628/src/testdir/test_options.vim 2020-04-13 21:16:18.039292270 +0200 --- src/testdir/test_options.vim 2020-04-24 20:26:49.778973063 +0200 *************** *** 899,902 **** --- 899,916 ---- 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 *** ../vim-8.2.0628/src/version.c 2020-04-23 23:53:56.837563312 +0200 --- src/version.c 2020-04-24 20:24:58.499360662 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 629, /**/ -- 10e12 microphone == 1 megaphone /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///