patch 8.2.2013: Vim9: not skipping white space after unary minus
Problem: Vim9: not skipping white space after unary minus.
Solution: Skip whitespace. (closes #7324)
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index b7897fe..156d244 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -2300,12 +2300,29 @@
CheckScriptSuccess(lines)
enddef
-def Test_expr7_negate()
+def Test_expr7_negate_add()
assert_equal(-99, -99)
+ assert_equal(-99, - 99)
assert_equal(99, --99)
+ assert_equal(99, -- 99)
+ assert_equal(99, - - 99)
+ assert_equal(99, +99)
+ assert_equal(-99, -+99)
+ assert_equal(-99, -+ 99)
+ assert_equal(-99, - +99)
+ assert_equal(-99, - + 99)
+ assert_equal(-99, +-99)
+ assert_equal(-99, + -99)
+ assert_equal(-99, + - 99)
+
var nr = 88
assert_equal(-88, -nr)
- assert_equal(88, --nr)
+ assert_equal(-88, - nr)
+ assert_equal(-88, - +nr)
+ assert_equal(88, -- nr)
+ assert_equal(88, + nr)
+ assert_equal(88, --+ nr)
+ assert_equal(88, - - nr)
enddef
def Echo(arg: any): string
diff --git a/src/version.c b/src/version.c
index 0f0ccda..3f5cd79 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2013,
+/**/
2012,
/**/
2011,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index c5d92aa..2c52280 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3362,6 +3362,8 @@
while (p > start)
{
--p;
+ while (VIM_ISWHITE(*p))
+ --p;
if (*p == '-' || *p == '+')
{
int negate = *p == '-';