mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07: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:
parent
2af6bbcfa7
commit
4ce20f7229
@ -2978,7 +2978,7 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
|
||||
case '#':
|
||||
if ((*arg)[1] == '{') {
|
||||
(*arg)++;
|
||||
ret = eval_dict(arg, rettv, flags, true);
|
||||
ret = eval_dict(arg, rettv, evalarg, true);
|
||||
} else {
|
||||
ret = NOTDONE;
|
||||
}
|
||||
@ -2989,7 +2989,7 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
|
||||
case '{':
|
||||
ret = get_lambda_tv(arg, rettv, evaluate);
|
||||
if (ret == NOTDONE) {
|
||||
ret = eval_dict(arg, rettv, flags, false);
|
||||
ret = eval_dict(arg, rettv, evalarg, false);
|
||||
}
|
||||
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.
|
||||
///
|
||||
/// @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;
|
||||
char *key = NULL;
|
||||
char *curly_expr = skipwhite(*arg + 1);
|
||||
char buf[NUMBUFLEN];
|
||||
|
||||
evalarg_T evalarg = { .eval_flags = flags };
|
||||
|
||||
// First check if it's not a curly-braces expression: {expr}.
|
||||
// Must do this without evaluating, otherwise a function may be called
|
||||
// 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) {
|
||||
if ((literal
|
||||
? get_literal_key(arg, &tvkey)
|
||||
: eval1(arg, &tvkey, &evalarg)) == FAIL) { // recursive!
|
||||
: eval1(arg, &tvkey, evalarg)) == FAIL) { // recursive!
|
||||
goto failret;
|
||||
}
|
||||
if (**arg != ':') {
|
||||
@ -4691,7 +4689,7 @@ static int eval_dict(char **arg, typval_T *rettv, const int flags, bool literal)
|
||||
}
|
||||
|
||||
*arg = skipwhite(*arg + 1);
|
||||
if (eval1(arg, &tv, &evalarg) == FAIL) { // Recursive!
|
||||
if (eval1(arg, &tv, evalarg) == FAIL) { // Recursive!
|
||||
if (evaluate) {
|
||||
tv_clear(&tvkey);
|
||||
}
|
||||
@ -4714,14 +4712,19 @@ static int eval_dict(char **arg, typval_T *rettv, const int flags, bool literal)
|
||||
}
|
||||
tv_clear(&tvkey);
|
||||
|
||||
// the comma must come after the value
|
||||
bool had_comma = **arg == ',';
|
||||
if (had_comma) {
|
||||
*arg = skipwhite(*arg + 1);
|
||||
}
|
||||
|
||||
if (**arg == '}') {
|
||||
break;
|
||||
}
|
||||
if (**arg != ',') {
|
||||
if (!had_comma) {
|
||||
semsg(_("E722: Missing comma in Dictionary: %s"), *arg);
|
||||
goto failret;
|
||||
}
|
||||
*arg = skipwhite(*arg + 1);
|
||||
}
|
||||
|
||||
if (**arg != '}') {
|
||||
|
Loading…
Reference in New Issue
Block a user