Mercurial > vim
comparison src/eval.c @ 6849:f4e5704c5c43 v7.4.745
patch 7.4.745
Problem: The entries added by matchaddpos() are returned by getmatches()
but can't be set with setmatches(). (Lcd)
Solution: Fix setmatches(). (Christian Brabandt)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 19 Jun 2015 16:32:57 +0200 |
parents | 541abe8d5f55 |
children | 566e193323ce |
comparison
equal
deleted
inserted
replaced
6848:359cbd05bea5 | 6849:f4e5704c5c43 |
---|---|
17116 { | 17116 { |
17117 #ifdef FEAT_SEARCH_EXTRA | 17117 #ifdef FEAT_SEARCH_EXTRA |
17118 list_T *l; | 17118 list_T *l; |
17119 listitem_T *li; | 17119 listitem_T *li; |
17120 dict_T *d; | 17120 dict_T *d; |
17121 list_T *s = NULL; | |
17121 | 17122 |
17122 rettv->vval.v_number = -1; | 17123 rettv->vval.v_number = -1; |
17123 if (argvars[0].v_type != VAR_LIST) | 17124 if (argvars[0].v_type != VAR_LIST) |
17124 { | 17125 { |
17125 EMSG(_(e_listreq)); | 17126 EMSG(_(e_listreq)); |
17138 { | 17139 { |
17139 EMSG(_(e_invarg)); | 17140 EMSG(_(e_invarg)); |
17140 return; | 17141 return; |
17141 } | 17142 } |
17142 if (!(dict_find(d, (char_u *)"group", -1) != NULL | 17143 if (!(dict_find(d, (char_u *)"group", -1) != NULL |
17143 && dict_find(d, (char_u *)"pattern", -1) != NULL | 17144 && (dict_find(d, (char_u *)"pattern", -1) != NULL |
17145 || dict_find(d, (char_u *)"pos1", -1) != NULL) | |
17144 && dict_find(d, (char_u *)"priority", -1) != NULL | 17146 && dict_find(d, (char_u *)"priority", -1) != NULL |
17145 && dict_find(d, (char_u *)"id", -1) != NULL)) | 17147 && dict_find(d, (char_u *)"id", -1) != NULL)) |
17146 { | 17148 { |
17147 EMSG(_(e_invarg)); | 17149 EMSG(_(e_invarg)); |
17148 return; | 17150 return; |
17152 | 17154 |
17153 clear_matches(curwin); | 17155 clear_matches(curwin); |
17154 li = l->lv_first; | 17156 li = l->lv_first; |
17155 while (li != NULL) | 17157 while (li != NULL) |
17156 { | 17158 { |
17159 int i = 0; | |
17160 char_u buf[4]; | |
17161 dictitem_T *di; | |
17162 | |
17157 d = li->li_tv.vval.v_dict; | 17163 d = li->li_tv.vval.v_dict; |
17158 match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE), | 17164 |
17165 if (dict_find(d, (char_u *)"pattern", -1) == NULL) | |
17166 { | |
17167 if (s == NULL) | |
17168 { | |
17169 s = list_alloc(); | |
17170 if (s == NULL) | |
17171 return; | |
17172 } | |
17173 | |
17174 /* match from matchaddpos() */ | |
17175 for (i = 1; i < 9; i++) | |
17176 { | |
17177 sprintf((char *)buf, (char *)"pos%d", i); | |
17178 if ((di = dict_find(d, (char_u *)buf, -1)) != NULL) | |
17179 { | |
17180 if (di->di_tv.v_type != VAR_LIST) | |
17181 return; | |
17182 | |
17183 list_append_tv(s, &di->di_tv); | |
17184 s->lv_refcount++; | |
17185 } | |
17186 else | |
17187 break; | |
17188 } | |
17189 } | |
17190 if (i == 0) | |
17191 { | |
17192 match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE), | |
17159 get_dict_string(d, (char_u *)"pattern", FALSE), | 17193 get_dict_string(d, (char_u *)"pattern", FALSE), |
17160 (int)get_dict_number(d, (char_u *)"priority"), | 17194 (int)get_dict_number(d, (char_u *)"priority"), |
17161 (int)get_dict_number(d, (char_u *)"id"), NULL); | 17195 (int)get_dict_number(d, (char_u *)"id"), NULL); |
17196 } | |
17197 else | |
17198 { | |
17199 match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE), | |
17200 NULL, (int)get_dict_number(d, (char_u *)"priority"), | |
17201 (int)get_dict_number(d, (char_u *)"id"), s); | |
17202 list_unref(s); | |
17203 s = NULL; | |
17204 } | |
17205 | |
17162 li = li->li_next; | 17206 li = li->li_next; |
17163 } | 17207 } |
17164 rettv->vval.v_number = 0; | 17208 rettv->vval.v_number = 0; |
17165 } | 17209 } |
17166 #endif | 17210 #endif |