0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

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)
This commit is contained in:
Bram Moolenaar
2020-11-18 17:39:05 +01:00
parent d92cc130fb
commit 79cdf80bed
3 changed files with 23 additions and 2 deletions

View File

@@ -2300,11 +2300,28 @@ def Test_expr7_parens_vim9script()
CheckScriptSuccess(lines) CheckScriptSuccess(lines)
enddef 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)
assert_equal(-99, + -99)
assert_equal(-99, + - 99)
var nr = 88 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) assert_equal(88, - - nr)
enddef enddef

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2013,
/**/ /**/
2012, 2012,
/**/ /**/

View File

@@ -3362,6 +3362,8 @@ compile_leader(cctx_T *cctx, int numeric_only, char_u *start, char_u **end)
while (p > start) while (p > start)
{ {
--p; --p;
while (VIM_ISWHITE(*p))
--p;
if (*p == '-' || *p == '+') if (*p == '-' || *p == '+')
{ {
int negate = *p == '-'; int negate = *p == '-';