]> granicus.if.org Git - vim/commitdiff
patch 8.2.2969: subtracting from number option fails when result is zero v8.2.2969
authorBram Moolenaar <Bram@vim.org>
Thu, 10 Jun 2021 16:43:25 +0000 (18:43 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 10 Jun 2021 16:43:25 +0000 (18:43 +0200)
Problem:    Subtracting from number option fails when result is zero. (Ingo
            Karkat)
Solution:   Reset the string value when using the numeric value.
            (closes #8351)

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

index f3b4da222bf36e1e452d9f6524ef765cb4e01586..7581a14177362acb1fda7224746b3b7abdf7c06a 100644 (file)
@@ -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)
index f12d810e02cb5a2a4d81b986ef695974d7cf299e..89c100189b567b6cd28aa6cdcbc7ebe8524d4fbd 100644 (file)
@@ -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:')
index d03113602881524abd58063c10b24537351ff0db..055179cd2d83e733169cb749e82683778608718a 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2969,
 /**/
     2968,
 /**/