changeset 24862:f1a390885192 v8.2.2969

patch 8.2.2969: subtracting from number option fails when result is zero Commit: https://github.com/vim/vim/commit/a42e6e0082a6d564dbfa55317d4a698ac12ae898 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 10 18:43:25 2021 +0200 patch 8.2.2969: subtracting from number option fails when result is zero Problem: Subtracting from number option fails when result is zero. (Ingo Karkat) Solution: Reset the string value when using the numeric value. (closes #8351)
author Bram Moolenaar <Bram@vim.org>
date Thu, 10 Jun 2021 18:45:03 +0200
parents 97f000974cc2
children d88997236cab
files src/evalvars.c src/testdir/test_vimscript.vim src/version.c
diffstat 3 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -1439,6 +1439,7 @@ ex_let_one(
 			    case '%': n = (long)num_modulus(numval, n,
 							       &failed); break;
 			}
+			s = NULL;
 		    }
 		    else if (opt_type == gov_string
 					     && stringval != NULL && s != NULL)
--- a/src/testdir/test_vimscript.vim
+++ b/src/testdir/test_vimscript.vim
@@ -7083,6 +7083,15 @@ func Test_compound_assignment_operators(
     call assert_fails('let &scrolljump .= "j"', 'E734:')
     set scrolljump&vim
 
+    let &foldlevelstart = 2
+    let &foldlevelstart -= 1
+    call assert_equal(1, &foldlevelstart)
+    let &foldlevelstart -= 1
+    call assert_equal(0, &foldlevelstart)
+    let &foldlevelstart = 2
+    let &foldlevelstart -= 2
+    call assert_equal(0, &foldlevelstart)
+
     " Test for register
     let @/ = 1
     call assert_fails('let @/ += 1', 'E734:')
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2969,
+/**/
     2968,
 /**/
     2967,