1
0
forked from aniani/vim

patch 9.1.1232: Vim script is missing the tuple data type

Problem:  Vim script is missing the tuple data type
Solution: Add support for the tuple data type
          (Yegappan Lakshmanan)

closes: #16776

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yegappan Lakshmanan
2025-03-23 16:42:16 +01:00
committed by Christian Brabandt
parent adb703e1b9
commit 9cb865e95b
75 changed files with 7155 additions and 691 deletions

View File

@@ -267,6 +267,7 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
char_u *res;
blob_T *b;
list_T *l;
tuple_T *tuple;
dict_T *d;
int i;
@@ -369,6 +370,42 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
}
break;
case VAR_TUPLE:
tuple = val->vval.v_tuple;
if (tuple == NULL)
ga_concat(gap, (char_u *)"[]");
else
{
if (tuple->tv_copyID == copyID)
ga_concat(gap, (char_u *)"[]");
else
{
int len = TUPLE_LEN(tuple);
tuple->tv_copyID = copyID;
ga_append(gap, '[');
for (i = 0; i < len && !got_int; i++)
{
typval_T *t_item = TUPLE_ITEM(tuple, i);
if (json_encode_item(gap, t_item, copyID,
options & JSON_JS) == FAIL)
return FAIL;
if ((options & JSON_JS)
&& i == len - 1
&& t_item->v_type == VAR_SPECIAL
&& t_item->vval.v_number == VVAL_NONE)
// add an extra comma if the last item is v:none
ga_append(gap, ',');
if (i <= len - 2)
ga_append(gap, ',');
}
ga_append(gap, ']');
tuple->tv_copyID = 0;
}
}
break;
case VAR_DICT:
d = val->vval.v_dict;
if (d == NULL)