forked from aniani/vim
patch 7.4.1608
Problem: string() doesn't handle a partial. Solution: Make a string from a partial.
This commit is contained in:
parent
f0e86a0dbd
commit
5c29154b52
44
src/eval.c
44
src/eval.c
@ -7897,9 +7897,49 @@ tv2string(
|
|||||||
*tofree = string_quote(tv->vval.v_string, TRUE);
|
*tofree = string_quote(tv->vval.v_string, TRUE);
|
||||||
return *tofree;
|
return *tofree;
|
||||||
case VAR_PARTIAL:
|
case VAR_PARTIAL:
|
||||||
*tofree = string_quote(tv->vval.v_partial == NULL ? NULL
|
{
|
||||||
: tv->vval.v_partial->pt_name, TRUE);
|
partial_T *pt = tv->vval.v_partial;
|
||||||
|
char_u *fname = string_quote(pt == NULL ? NULL
|
||||||
|
: pt->pt_name, FALSE);
|
||||||
|
garray_T ga;
|
||||||
|
int i;
|
||||||
|
char_u *tf;
|
||||||
|
|
||||||
|
ga_init2(&ga, 1, 100);
|
||||||
|
ga_concat(&ga, (char_u *)"function(");
|
||||||
|
if (fname != NULL)
|
||||||
|
{
|
||||||
|
ga_concat(&ga, fname);
|
||||||
|
vim_free(fname);
|
||||||
|
}
|
||||||
|
if (pt != NULL && pt->pt_argc > 0)
|
||||||
|
{
|
||||||
|
ga_concat(&ga, (char_u *)", [");
|
||||||
|
for (i = 0; i < pt->pt_argc; ++i)
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
ga_concat(&ga, (char_u *)", ");
|
||||||
|
ga_concat(&ga,
|
||||||
|
tv2string(&pt->pt_argv[i], &tf, numbuf, copyID));
|
||||||
|
vim_free(tf);
|
||||||
|
}
|
||||||
|
ga_concat(&ga, (char_u *)"]");
|
||||||
|
}
|
||||||
|
if (pt != NULL && pt->pt_dict != NULL)
|
||||||
|
{
|
||||||
|
typval_T dtv;
|
||||||
|
|
||||||
|
ga_concat(&ga, (char_u *)", ");
|
||||||
|
dtv.v_type = VAR_DICT;
|
||||||
|
dtv.vval.v_dict = pt->pt_dict;
|
||||||
|
ga_concat(&ga, tv2string(&dtv, &tf, numbuf, copyID));
|
||||||
|
vim_free(tf);
|
||||||
|
}
|
||||||
|
ga_concat(&ga, (char_u *)")");
|
||||||
|
|
||||||
|
*tofree = ga.ga_data;
|
||||||
return *tofree;
|
return *tofree;
|
||||||
|
}
|
||||||
case VAR_STRING:
|
case VAR_STRING:
|
||||||
*tofree = string_quote(tv->vval.v_string, FALSE);
|
*tofree = string_quote(tv->vval.v_string, FALSE);
|
||||||
return *tofree;
|
return *tofree;
|
||||||
|
@ -156,3 +156,17 @@ func Test_partial_exists()
|
|||||||
let lF = [F]
|
let lF = [F]
|
||||||
call assert_true(exists('*lF[0]'))
|
call assert_true(exists('*lF[0]'))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_partial_string()
|
||||||
|
let F = function('MyFunc')
|
||||||
|
call assert_equal("function('MyFunc')", string(F))
|
||||||
|
let F = function('MyFunc', ['foo'])
|
||||||
|
call assert_equal("function('MyFunc', ['foo'])", string(F))
|
||||||
|
let F = function('MyFunc', ['foo', 'bar'])
|
||||||
|
call assert_equal("function('MyFunc', ['foo', 'bar'])", string(F))
|
||||||
|
let d = {'one': 1}
|
||||||
|
let F = function('MyFunc', d)
|
||||||
|
call assert_equal("function('MyFunc', {'one': 1})", string(F))
|
||||||
|
let F = function('MyFunc', ['foo'], d)
|
||||||
|
call assert_equal("function('MyFunc', ['foo'], {'one': 1})", string(F))
|
||||||
|
endfunc
|
||||||
|
@ -748,6 +748,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 */
|
||||||
|
/**/
|
||||||
|
1608,
|
||||||
/**/
|
/**/
|
||||||
1607,
|
1607,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user