diff options
-rw-r--r-- | src/eval.c | 20 | ||||
-rw-r--r-- | src/testdir/test104.in | 16 | ||||
-rw-r--r-- | src/testdir/test104.ok | 11 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 38 insertions, 11 deletions
diff --git a/src/eval.c b/src/eval.c index fa5a920939..adb47d38b7 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1751,11 +1751,10 @@ void ex_let(exarg_T *eap) return; if (argend > arg && argend[-1] == '.') /* for var.='str' */ --argend; - expr = vim_strchr(argend, '='); - if (expr == NULL) { - /* - * ":let" without "=": list variables - */ + expr = skipwhite(argend); + if (*expr != '=' && !(vim_strchr((char_u *)"+-.", *expr) != NULL + && expr[1] == '=')) { + // ":let" without "=": list variables if (*arg == '[') EMSG(_(e_invarg)); else if (!ends_excmd(*arg)) @@ -1775,11 +1774,14 @@ void ex_let(exarg_T *eap) } else { op[0] = '='; op[1] = NUL; - if (expr > argend) { - if (vim_strchr((char_u *)"+-.", expr[-1]) != NULL) - op[0] = expr[-1]; /* +=, -= or .= */ + if (*expr != '=') { + if (vim_strchr((char_u *)"+-.", *expr) != NULL) { + op[0] = *expr; // +=, -=, .= + } + expr = skipwhite(expr + 2); + } else { + expr = skipwhite(expr + 1); } - expr = skipwhite(expr + 1); if (eap->skip) ++emsg_skip; diff --git a/src/testdir/test104.in b/src/testdir/test104.in index f329d2dbed..fd847131e9 100644 --- a/src/testdir/test104.in +++ b/src/testdir/test104.in @@ -1,4 +1,4 @@ -Tests for autoload. vim: set ft=vim ts=8 : +Tests for :let. vim: set ft=vim ts=8 : STARTTEST :so small.vim @@ -10,6 +10,20 @@ STARTTEST :catch : $put ='FAIL: ' . v:exception :endtry +:let a = 1 +:let b = 2 +:for letargs in ['a b', '{0 == 1 ? "a" : "b"}', '{0 == 1 ? "a" : "b"} a', 'a {0 == 1 ? "a" : "b"}'] +: try +: redir => messages +: execute 'let' letargs +: redir END +: $put ='OK:' +: $put =split(substitute(messages, '\n', '\0 ', 'g'), '\n') +: catch +: $put ='FAIL: ' . v:exception +: redir END +: endtry +:endfor :/^Results/,$wq! test.out ENDTEST diff --git a/src/testdir/test104.ok b/src/testdir/test104.ok index 5c16509af9..5fb20945c3 100644 --- a/src/testdir/test104.ok +++ b/src/testdir/test104.ok @@ -1,2 +1,13 @@ Results of test104: OK: function('tr') +OK: + a #1 + b #2 +OK: + b #2 +OK: + b #2 + a #1 +OK: + a #1 + b #2 diff --git a/src/version.c b/src/version.c index 6dfc371f4a..4955dea885 100644 --- a/src/version.c +++ b/src/version.c @@ -232,7 +232,7 @@ static int included_patches[] = { //232, //231, //230, - //229, + 229, //228, //227, //226, |