mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 16:58:17 +00:00
vim-patch:8.2.1068: Vim9: no line break allowed inside a dict
Problem: Vim9: no line break allowed inside a dict.
Solution: Handle line break inside a dict in Vim9 script.
8ea9390b78
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -2978,7 +2978,7 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
|
|||||||
case '#':
|
case '#':
|
||||||
if ((*arg)[1] == '{') {
|
if ((*arg)[1] == '{') {
|
||||||
(*arg)++;
|
(*arg)++;
|
||||||
ret = eval_dict(arg, rettv, flags, true);
|
ret = eval_dict(arg, rettv, evalarg, true);
|
||||||
} else {
|
} else {
|
||||||
ret = NOTDONE;
|
ret = NOTDONE;
|
||||||
}
|
}
|
||||||
@@ -2989,7 +2989,7 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
|
|||||||
case '{':
|
case '{':
|
||||||
ret = get_lambda_tv(arg, rettv, evaluate);
|
ret = get_lambda_tv(arg, rettv, evaluate);
|
||||||
if (ret == NOTDONE) {
|
if (ret == NOTDONE) {
|
||||||
ret = eval_dict(arg, rettv, flags, false);
|
ret = eval_dict(arg, rettv, evalarg, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -4638,16 +4638,14 @@ static int get_literal_key(char **arg, typval_T *tv)
|
|||||||
/// @param flags can have EVAL_EVALUATE and other EVAL_ flags.
|
/// @param flags can have EVAL_EVALUATE and other EVAL_ flags.
|
||||||
///
|
///
|
||||||
/// @return OK or FAIL. Returns NOTDONE for {expr}.
|
/// @return OK or FAIL. Returns NOTDONE for {expr}.
|
||||||
static int eval_dict(char **arg, typval_T *rettv, const int flags, bool literal)
|
static int eval_dict(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool literal)
|
||||||
{
|
{
|
||||||
const bool evaluate = flags & EVAL_EVALUATE;
|
const bool evaluate = evalarg == NULL ? false : evalarg->eval_flags & EVAL_EVALUATE;
|
||||||
typval_T tv;
|
typval_T tv;
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
char *curly_expr = skipwhite(*arg + 1);
|
char *curly_expr = skipwhite(*arg + 1);
|
||||||
char buf[NUMBUFLEN];
|
char buf[NUMBUFLEN];
|
||||||
|
|
||||||
evalarg_T evalarg = { .eval_flags = flags };
|
|
||||||
|
|
||||||
// First check if it's not a curly-braces expression: {expr}.
|
// First check if it's not a curly-braces expression: {expr}.
|
||||||
// Must do this without evaluating, otherwise a function may be called
|
// Must do this without evaluating, otherwise a function may be called
|
||||||
// twice. Unfortunately this means we need to call eval1() twice for the
|
// twice. Unfortunately this means we need to call eval1() twice for the
|
||||||
@@ -4673,7 +4671,7 @@ static int eval_dict(char **arg, typval_T *rettv, const int flags, bool literal)
|
|||||||
while (**arg != '}' && **arg != NUL) {
|
while (**arg != '}' && **arg != NUL) {
|
||||||
if ((literal
|
if ((literal
|
||||||
? get_literal_key(arg, &tvkey)
|
? get_literal_key(arg, &tvkey)
|
||||||
: eval1(arg, &tvkey, &evalarg)) == FAIL) { // recursive!
|
: eval1(arg, &tvkey, evalarg)) == FAIL) { // recursive!
|
||||||
goto failret;
|
goto failret;
|
||||||
}
|
}
|
||||||
if (**arg != ':') {
|
if (**arg != ':') {
|
||||||
@@ -4691,7 +4689,7 @@ static int eval_dict(char **arg, typval_T *rettv, const int flags, bool literal)
|
|||||||
}
|
}
|
||||||
|
|
||||||
*arg = skipwhite(*arg + 1);
|
*arg = skipwhite(*arg + 1);
|
||||||
if (eval1(arg, &tv, &evalarg) == FAIL) { // Recursive!
|
if (eval1(arg, &tv, evalarg) == FAIL) { // Recursive!
|
||||||
if (evaluate) {
|
if (evaluate) {
|
||||||
tv_clear(&tvkey);
|
tv_clear(&tvkey);
|
||||||
}
|
}
|
||||||
@@ -4714,14 +4712,19 @@ static int eval_dict(char **arg, typval_T *rettv, const int flags, bool literal)
|
|||||||
}
|
}
|
||||||
tv_clear(&tvkey);
|
tv_clear(&tvkey);
|
||||||
|
|
||||||
|
// the comma must come after the value
|
||||||
|
bool had_comma = **arg == ',';
|
||||||
|
if (had_comma) {
|
||||||
|
*arg = skipwhite(*arg + 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (**arg == '}') {
|
if (**arg == '}') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (**arg != ',') {
|
if (!had_comma) {
|
||||||
semsg(_("E722: Missing comma in Dictionary: %s"), *arg);
|
semsg(_("E722: Missing comma in Dictionary: %s"), *arg);
|
||||||
goto failret;
|
goto failret;
|
||||||
}
|
}
|
||||||
*arg = skipwhite(*arg + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (**arg != '}') {
|
if (**arg != '}') {
|
||||||
|
Reference in New Issue
Block a user