aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-02-02 15:55:15 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-02-29 17:40:00 -0500
commit3c12ee333a519c5be1d8f63d7978b483a51a3da7 (patch)
treeeacd0da0ae6a415dc3f2e3bb32dfb09cbaaa0c5b /src/nvim/eval.c
parent1656367b90bd29d84d5ebf1ccef560368a1973cf (diff)
downloadrneovim-3c12ee333a519c5be1d8f63d7978b483a51a3da7.tar.gz
rneovim-3c12ee333a519c5be1d8f63d7978b483a51a3da7.tar.bz2
rneovim-3c12ee333a519c5be1d8f63d7978b483a51a3da7.zip
vim-patch:8.1.0619: :echomsg and :echoerr do not handle List and Dict
Problem: :echomsg and :echoerr do not handle List and Dict like :echo does. (Daniel Hahler) Solution: Be more tolerant about the expression result type. https://github.com/vim/vim/commit/461a7fcfce3cd6414f990037e6468af3b5ccf119 Add lua functional tests for :echo,:echon,:echomsg,:echoerr because nvim did not port "test_" functions from Vim that modify internal state. Testing :echoerr via try/catch is sufficient.
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c26
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)) {