diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-09-08 08:12:10 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-09-08 08:15:55 +0800 |
commit | 93a0c2dd63e369528664037b118ff9b9b38a20d4 (patch) | |
tree | 8baf4e0bead7c077649960b005c3e9fe16b12d60 /src/nvim/eval.c | |
parent | ead524656dc1664622f80509a983519a190ca48a (diff) | |
download | rneovim-93a0c2dd63e369528664037b118ff9b9b38a20d4.tar.gz rneovim-93a0c2dd63e369528664037b118ff9b9b38a20d4.tar.bz2 rneovim-93a0c2dd63e369528664037b118ff9b9b38a20d4.zip |
vim-patch:8.2.3702: first key in dict is seen as curly expression and fails
Problem: First key in dict is seen as curly expression and fails.
Solution: Ignore failure of curly expression. (closes vim/vim#9247)
https://github.com/vim/vim/commit/98cb90ef865089a5ddd20bc0303d449fb7d97fb2
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0c41381313..1171695be3 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2997,7 +2997,9 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string) // decimal, hex or octal number vim_str2nr(*arg, NULL, &len, STR2NR_ALL, &n, NULL, 0, true); if (len == 0) { - semsg(_(e_invexpr2), *arg); + if (evaluate) { + semsg(_(e_invexpr2), *arg); + } ret = FAIL; break; } @@ -4582,7 +4584,7 @@ static int dict_get_tv(char **arg, typval_T *rettv, int evaluate, bool literal) { typval_T tv; char *key = NULL; - char *start = skipwhite(*arg + 1); + char *curly_expr = skipwhite(*arg + 1); char buf[NUMBUFLEN]; // First check if it's not a curly-braces thing: {expr}. @@ -4590,13 +4592,10 @@ static int dict_get_tv(char **arg, typval_T *rettv, int evaluate, bool literal) // twice. Unfortunately this means we need to call eval1() twice for the // first item. // But {} is an empty Dictionary. - if (*start != '}') { - if (eval1(&start, &tv, false) == FAIL) { // recursive! - return FAIL; - } - if (*skipwhite(start) == '}') { - return NOTDONE; - } + if (*curly_expr != '}' + && eval1(&curly_expr, &tv, false) == OK + && *skipwhite(curly_expr) == '}') { + return NOTDONE; } dict_T *d = NULL; |