1
0
forked from aniani/vim

patch 8.2.2941: Vim9: using does not handle a list of strings

Problem:    Vim9: using  does not handle a list of strings.
Solution:   Convert a list to a string and escape each item. (closes #8310)
This commit is contained in:
Bram Moolenaar
2021-06-05 17:10:55 +02:00
parent 4f2417ffee
commit b288ba9f1d
3 changed files with 30 additions and 5 deletions

View File

@@ -999,15 +999,34 @@ do_2string(typval_T *tv, int is_2string_any, int tolerant)
case VAR_LIST:
if (tolerant)
{
char_u *p;
char_u *s, *e, *p;
garray_T ga;
ga_init2(&ga, sizeof(char_u *), 1);
// Convert to NL separated items, then
// escape the items and replace the NL with
// a space.
str = typval2string(tv, TRUE);
if (str == NULL)
return FAIL;
s = str;
while ((e = vim_strchr(s, '\n')) != NULL)
{
*e = NUL;
p = vim_strsave_fnameescape(s, FALSE);
if (p != NULL)
{
ga_concat(&ga, p);
ga_concat(&ga, (char_u *)" ");
vim_free(p);
}
s = e + 1;
}
vim_free(str);
clear_tv(tv);
tv->v_type = VAR_STRING;
tv->vval.v_string = str;
// TODO: escaping
while ((p = vim_strchr(str, '\n')) != NULL)
*p = ' ';
tv->vval.v_string = ga.ga_data;
return OK;
}
// FALLTHROUGH