Mercurial > vim
changeset 5770:839cca5ec18d v7.4.229
updated for version 7.4.229
Problem: Using ":let" for listing variables and the second one is a curly
braces expression may fail.
Solution: Check for an "=" in a better way. (ZyX)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 30 Mar 2014 16:49:09 +0200 |
parents | 34723a1b096f |
children | 7b76ad980f09 |
files | src/eval.c src/testdir/test104.in src/testdir/test104.ok src/version.c |
diffstat | 4 files changed, 39 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -1856,8 +1856,9 @@ ex_let(eap) return; if (argend > arg && argend[-1] == '.') /* for var.='str' */ --argend; - expr = vim_strchr(argend, '='); - if (expr == NULL) + expr = skipwhite(argend); + if (*expr != '=' && !(vim_strchr((char_u *)"+-.", *expr) != NULL + && expr[1] == '=')) { /* * ":let" without "=": list variables @@ -1886,12 +1887,14 @@ ex_let(eap) { op[0] = '='; op[1] = NUL; - if (expr > argend) - { - if (vim_strchr((char_u *)"+-.", expr[-1]) != NULL) - op[0] = expr[-1]; /* +=, -= or .= */ - } - expr = skipwhite(expr + 1); + if (*expr != '=') + { + if (vim_strchr((char_u *)"+-.", *expr) != NULL) + op[0] = *expr; /* +=, -= or .= */ + expr = skipwhite(expr + 2); + } + else + expr = skipwhite(expr + 1); if (eap->skip) ++emsg_skip;
--- 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