diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-12-22 13:28:07 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-12-22 13:28:07 +0100 |
commit | 461a7fcfce3cd6414f990037e6468af3b5ccf119 (patch) | |
tree | 6498b1cf892206698e8b6951af503f6a953bf5ac /src/eval.c | |
parent | 528ccfbaa1cc805f430a750c551e5a9fd7eb54fe (diff) | |
download | vim-git-461a7fcfce3cd6414f990037e6468af3b5ccf119.tar.gz |
patch 8.1.0619: :echomsg and :echoerr do not handle List and Dictv8.1.0619
Problem: :echomsg and :echoerr do not handle List and Dict like :echo does.
(Daniel Hahler)
Solution: Be more tolerant about the expression result type.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c index 1d14e1b0e..b6463d2e7 100644 --- a/src/eval.c +++ b/src/eval.c @@ -7163,6 +7163,30 @@ tv_get_string_buf_chk(typval_T *varp, char_u *buf) } /* + * Turn a typeval into a string. Similar to tv_get_string_buf() but uses + * string() on Dict, List, etc. + */ + char_u * +tv_stringify(typval_T *varp, char_u *buf) +{ + 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); + tv_get_string_buf(&tmp, buf); + clear_tv(varp); + *varp = tmp; + return tmp.vval.v_string; + } + 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. @@ -8142,7 +8166,12 @@ ex_execute(exarg_T *eap) if (!eap->skip) { - p = tv_get_string(&rettv); + char_u buf[NUMBUFLEN]; + + if (eap->cmdidx == CMD_execute) + p = tv_get_string_buf(&rettv, buf); + else + p = tv_stringify(&rettv, buf); len = (int)STRLEN(p); if (ga_grow(&ga, len + 2) == FAIL) { |