neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit d8df9afad62a9a4beb4ec607f8e10d674de66dbe
parent 963ea726daf3e19279f8e24b48116f11f1921c7d
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Mon, 25 Jul 2022 18:11:37 +0800

vim-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 vim/vim#8351)
https://github.com/vim/vim/commit/a42e6e0082a6d564dbfa55317d4a698ac12ae898

Cherry-pick Test_compound_assignment_operators() changes from patch 8.2.1593

Diffstat:
Msrc/nvim/eval/vars.c | 1+
Msrc/nvim/testdir/test_vimscript.vim | 21+++++++++++++++------
2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c @@ -663,6 +663,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo case '%': n = num_modulus(numval, n); break; } + s = NULL; } else if (opt_type == gov_string && stringval != NULL && s != NULL) { // string char *const oldstringval = stringval; diff --git a/src/nvim/testdir/test_vimscript.vim b/src/nvim/testdir/test_vimscript.vim @@ -1661,16 +1661,25 @@ func Test_compound_assignment_operators() call assert_equal(6, &scrolljump) let &scrolljump %= 5 call assert_equal(1, &scrolljump) - call assert_fails('let &scrolljump .= "j"', 'E734') + 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') - call assert_fails('let @/ -= 1', 'E734') - call assert_fails('let @/ *= 1', 'E734') - call assert_fails('let @/ /= 1', 'E734') - call assert_fails('let @/ %= 1', 'E734') + call assert_fails('let @/ += 1', 'E734:') + call assert_fails('let @/ -= 1', 'E734:') + call assert_fails('let @/ *= 1', 'E734:') + call assert_fails('let @/ /= 1', 'E734:') + call assert_fails('let @/ %= 1', 'E734:') let @/ .= 's' call assert_equal('1s', @/) let @/ = ''