changeset 22932:87b62395a4d1 v8.2.2013

patch 8.2.2013: Vim9: not skipping white space after unary minus Commit: https://github.com/vim/vim/commit/79cdf80bed3192add70882bc0aaeede91cc74300 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Nov 18 17:39:05 2020 +0100 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 https://github.com/vim/vim/issues/7324)
author Bram Moolenaar <Bram@vim.org>
date Wed, 18 Nov 2020 17:45:03 +0100
parents 7b03a3108d09
children f5066b74b9af
files src/testdir/test_vim9_expr.vim src/version.c src/vim9compile.c
diffstat 3 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -2300,12 +2300,29 @@ def Test_expr7_parens_vim9script()
   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
--- 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 */
 /**/
+    2013,
+/**/
     2012,
 /**/
     2011,
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3362,6 +3362,8 @@ compile_leader(cctx_T *cctx, int numeric
     while (p > start)
     {
 	--p;
+	while (VIM_ISWHITE(*p))
+	    --p;
 	if (*p == '-' || *p == '+')
 	{
 	    int	    negate = *p == '-';