mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
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:
@@ -34,6 +34,10 @@ def Test_edit_wildcards()
|
|||||||
|
|
||||||
CheckDefFailure(['edit `=xxx`'], 'E1001:')
|
CheckDefFailure(['edit `=xxx`'], 'E1001:')
|
||||||
CheckDefFailure(['edit `="foo"'], 'E1083:')
|
CheckDefFailure(['edit `="foo"'], 'E1083:')
|
||||||
|
|
||||||
|
var files = ['file 1', 'file%2', 'file# 3']
|
||||||
|
args `=files`
|
||||||
|
assert_equal(files, argv())
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_expand_alternate_file()
|
def Test_expand_alternate_file()
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2941,
|
||||||
/**/
|
/**/
|
||||||
2940,
|
2940,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -999,15 +999,34 @@ do_2string(typval_T *tv, int is_2string_any, int tolerant)
|
|||||||
case VAR_LIST:
|
case VAR_LIST:
|
||||||
if (tolerant)
|
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);
|
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);
|
clear_tv(tv);
|
||||||
tv->v_type = VAR_STRING;
|
tv->v_type = VAR_STRING;
|
||||||
tv->vval.v_string = str;
|
tv->vval.v_string = ga.ga_data;
|
||||||
// TODO: escaping
|
|
||||||
while ((p = vim_strchr(str, '\n')) != NULL)
|
|
||||||
*p = ' ';
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
// FALLTHROUGH
|
// FALLTHROUGH
|
||||||
|
Reference in New Issue
Block a user