diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-04-14 12:55:09 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-04-14 16:10:09 +0800 |
commit | 2af6bbcfa70863df7b6068059f9d504c7894e154 (patch) | |
tree | e446e3333893407e6e98732caa941e5740072d5a /src/nvim/eval.c | |
parent | 51f99a347d181e16ccd80604f553b4b985991817 (diff) | |
download | rneovim-2af6bbcfa70863df7b6068059f9d504c7894e154.tar.gz rneovim-2af6bbcfa70863df7b6068059f9d504c7894e154.tar.bz2 rneovim-2af6bbcfa70863df7b6068059f9d504c7894e154.zip |
vim-patch:8.2.1065: Vim9: no line break allowed inside a list
Problem: Vim9: no line break allowed inside a list.
Solution: Handle line break inside a list in Vim9 script.
https://github.com/vim/vim/commit/7147820cb978f5b179cfec2f9d8b7774e28d43e0
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0396b01771..8ea78cb5d4 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2971,7 +2971,7 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan // List: [expr, expr] case '[': - ret = get_list_tv(arg, rettv, flags); + ret = get_list_tv(arg, rettv, evalarg); break; // Dictionary: #{key: val, key: val} @@ -3981,14 +3981,13 @@ void partial_unref(partial_T *pt) /// Allocate a variable for a List and fill it from "*arg". /// +/// @param arg "*arg" points to the "[". /// @return OK or FAIL. -static int get_list_tv(char **arg, typval_T *rettv, const int flags) +static int get_list_tv(char **arg, typval_T *rettv, evalarg_T *const evalarg) { - const bool evaluate = flags & EVAL_EVALUATE; + const bool evaluate = evalarg == NULL ? false : evalarg->eval_flags & EVAL_EVALUATE; list_T *l = NULL; - evalarg_T evalarg = { .eval_flags = flags }; - if (evaluate) { l = tv_list_alloc(kListLenShouldKnow); } @@ -3996,7 +3995,7 @@ static int get_list_tv(char **arg, typval_T *rettv, const int flags) *arg = skipwhite(*arg + 1); while (**arg != ']' && **arg != NUL) { typval_T tv; - if (eval1(arg, &tv, &evalarg) == FAIL) { // Recursive! + if (eval1(arg, &tv, evalarg) == FAIL) { // Recursive! goto failret; } if (evaluate) { @@ -4004,14 +4003,20 @@ static int get_list_tv(char **arg, typval_T *rettv, const int flags) tv_list_append_owned_tv(l, tv); } + // the comma must comma after the value + bool had_comma = **arg == ','; + if (had_comma) { + *arg = skipwhite(*arg + 1); + } + if (**arg == ']') { break; } - if (**arg != ',') { + + if (!had_comma) { semsg(_("E696: Missing comma in List: %s"), *arg); goto failret; } - *arg = skipwhite(*arg + 1); } if (**arg != ']') { |