Mercurial > vim
comparison src/eval.c @ 15219:dada0b389d4f v8.1.0619
patch 8.1.0619: :echomsg and :echoerr do not handle List and Dict
commit https://github.com/vim/vim/commit/461a7fcfce3cd6414f990037e6468af3b5ccf119
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 22 13:28:07 2018 +0100
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 22 Dec 2018 13:30:08 +0100 |
parents | de63593896b3 |
children | 1d2b5c016f17 |
comparison
equal
deleted
inserted
replaced
15218:d8a6097d1f52 | 15219:dada0b389d4f |
---|---|
7161 } | 7161 } |
7162 return NULL; | 7162 return NULL; |
7163 } | 7163 } |
7164 | 7164 |
7165 /* | 7165 /* |
7166 * Turn a typeval into a string. Similar to tv_get_string_buf() but uses | |
7167 * string() on Dict, List, etc. | |
7168 */ | |
7169 char_u * | |
7170 tv_stringify(typval_T *varp, char_u *buf) | |
7171 { | |
7172 if (varp->v_type == VAR_LIST | |
7173 || varp->v_type == VAR_DICT | |
7174 || varp->v_type == VAR_FUNC | |
7175 || varp->v_type == VAR_PARTIAL | |
7176 || varp->v_type == VAR_FLOAT) | |
7177 { | |
7178 typval_T tmp; | |
7179 | |
7180 f_string(varp, &tmp); | |
7181 tv_get_string_buf(&tmp, buf); | |
7182 clear_tv(varp); | |
7183 *varp = tmp; | |
7184 return tmp.vval.v_string; | |
7185 } | |
7186 return tv_get_string_buf(varp, buf); | |
7187 } | |
7188 | |
7189 /* | |
7166 * Find variable "name" in the list of variables. | 7190 * Find variable "name" in the list of variables. |
7167 * Return a pointer to it if found, NULL if not found. | 7191 * Return a pointer to it if found, NULL if not found. |
7168 * Careful: "a:0" variables don't have a name. | 7192 * Careful: "a:0" variables don't have a name. |
7169 * When "htp" is not NULL we are writing to the variable, set "htp" to the | 7193 * When "htp" is not NULL we are writing to the variable, set "htp" to the |
7170 * hashtab_T used. | 7194 * hashtab_T used. |
8140 break; | 8164 break; |
8141 } | 8165 } |
8142 | 8166 |
8143 if (!eap->skip) | 8167 if (!eap->skip) |
8144 { | 8168 { |
8145 p = tv_get_string(&rettv); | 8169 char_u buf[NUMBUFLEN]; |
8170 | |
8171 if (eap->cmdidx == CMD_execute) | |
8172 p = tv_get_string_buf(&rettv, buf); | |
8173 else | |
8174 p = tv_stringify(&rettv, buf); | |
8146 len = (int)STRLEN(p); | 8175 len = (int)STRLEN(p); |
8147 if (ga_grow(&ga, len + 2) == FAIL) | 8176 if (ga_grow(&ga, len + 2) == FAIL) |
8148 { | 8177 { |
8149 clear_tv(&rettv); | 8178 clear_tv(&rettv); |
8150 ret = FAIL; | 8179 ret = FAIL; |