diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2020-02-29 17:37:15 -0800 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2020-02-29 17:37:15 -0800 |
commit | 1b0a7703406328f90edd907880fc4a3dbd1d7087 (patch) | |
tree | 5b5f273ce48f4c670e6223fd4b4559bcc645f603 /src/nvim/eval.c | |
parent | 6fcab7e758f3826b94ab369452b71d15a67c8b36 (diff) | |
parent | 3c12ee333a519c5be1d8f63d7978b483a51a3da7 (diff) | |
download | rneovim-1b0a7703406328f90edd907880fc4a3dbd1d7087.tar.gz rneovim-1b0a7703406328f90edd907880fc4a3dbd1d7087.tar.bz2 rneovim-1b0a7703406328f90edd907880fc4a3dbd1d7087.zip |
Merge #11805 'vim-patch:8.1.0619'
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 74a5edc0df..f5c5ef9e97 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -9459,6 +9459,27 @@ void set_selfdict(typval_T *rettv, dict_T *selfdict) } } +// Turn a typeval into a string. Similar to tv_get_string_buf() but uses +// string() on Dict, List, etc. +static const char *tv_stringify(typval_T *varp, char *buf) + FUNC_ATTR_NONNULL_ALL +{ + if (varp->v_type == VAR_LIST + || varp->v_type == VAR_DICT + || varp->v_type == VAR_FUNC + || varp->v_type == VAR_PARTIAL + || varp->v_type == VAR_FLOAT) { + typval_T tmp; + + f_string(varp, &tmp, NULL); + const char *const res = tv_get_string_buf(&tmp, buf); + tv_clear(varp); + *varp = tmp; + return res; + } + return tv_get_string_buf(varp, buf); +} + // Find variable "name" in the list of variables. // Return a pointer to it if found, NULL if not found. // Careful: "a:0" variables don't have a name. @@ -10349,7 +10370,10 @@ void ex_execute(exarg_T *eap) } if (!eap->skip) { - const char *const argstr = tv_get_string(&rettv); + char buf[NUMBUFLEN]; + const char *const argstr = eap->cmdidx == CMD_execute + ? tv_get_string_buf(&rettv, buf) + : tv_stringify(&rettv, buf); const size_t len = strlen(argstr); ga_grow(&ga, len + 2); if (!GA_EMPTY(&ga)) { |