@@ -17146,6 +17146,7 @@ f_setmatches(argvars, rettv)
1714617146 list_T *l;
1714717147 listitem_T *li;
1714817148 dict_T *d;
17149+ list_T *s = NULL;
1714917150
1715017151 rettv->vval.v_number = -1;
1715117152 if (argvars[0].v_type != VAR_LIST)
@@ -17168,7 +17169,8 @@ f_setmatches(argvars, rettv)
1716817169 return;
1716917170 }
1717017171 if (!(dict_find(d, (char_u *)"group", -1) != NULL
17171- && dict_find(d, (char_u *)"pattern", -1) != NULL
17172+ && (dict_find(d, (char_u *)"pattern", -1) != NULL
17173+ || dict_find(d, (char_u *)"pos1", -1) != NULL)
1717217174 && dict_find(d, (char_u *)"priority", -1) != NULL
1717317175 && dict_find(d, (char_u *)"id", -1) != NULL))
1717417176 {
@@ -17182,11 +17184,53 @@ f_setmatches(argvars, rettv)
1718217184 li = l->lv_first;
1718317185 while (li != NULL)
1718417186 {
17187+ int i = 0;
17188+ char_u buf[4];
17189+ dictitem_T *di;
17190+
1718517191 d = li->li_tv.vval.v_dict;
17186- match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
17192+
17193+ if (dict_find(d, (char_u *)"pattern", -1) == NULL)
17194+ {
17195+ if (s == NULL)
17196+ {
17197+ s = list_alloc();
17198+ if (s == NULL)
17199+ return;
17200+ }
17201+
17202+ /* match from matchaddpos() */
17203+ for (i = 1; i < 9; i++)
17204+ {
17205+ sprintf((char *)buf, (char *)"pos%d", i);
17206+ if ((di = dict_find(d, (char_u *)buf, -1)) != NULL)
17207+ {
17208+ if (di->di_tv.v_type != VAR_LIST)
17209+ return;
17210+
17211+ list_append_tv(s, &di->di_tv);
17212+ s->lv_refcount++;
17213+ }
17214+ else
17215+ break;
17216+ }
17217+ }
17218+ if (i == 0)
17219+ {
17220+ match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
1718717221 get_dict_string(d, (char_u *)"pattern", FALSE),
1718817222 (int)get_dict_number(d, (char_u *)"priority"),
1718917223 (int)get_dict_number(d, (char_u *)"id"), NULL);
17224+ }
17225+ else
17226+ {
17227+ match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
17228+ NULL, (int)get_dict_number(d, (char_u *)"priority"),
17229+ (int)get_dict_number(d, (char_u *)"id"), s);
17230+ list_unref(s);
17231+ s = NULL;
17232+ }
17233+
1719017234 li = li->li_next;
1719117235 }
1719217236 rettv->vval.v_number = 0;
0 commit comments