diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-02-01 02:49:27 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-02-01 02:49:27 -0500 |
commit | be1d5a61be3e75d4d2b15b76b2bb027605c70ff8 (patch) | |
tree | 292147ad917f6e0df65e32a078709cb850843397 /src/nvim/eval.c | |
parent | 59ef994f8f5fad9aaaa0e1d6eae3af66f6bb2630 (diff) | |
parent | 515b7e3effcab07f56d3e3ec74bdd2fae600aa10 (diff) | |
download | rneovim-be1d5a61be3e75d4d2b15b76b2bb027605c70ff8.tar.gz rneovim-be1d5a61be3e75d4d2b15b76b2bb027605c70ff8.tar.bz2 rneovim-be1d5a61be3e75d4d2b15b76b2bb027605c70ff8.zip |
Merge pull request #4129 from jbradaric/vim-7.4.745
vim-patch:7.4.{745,746,747,748}
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b591c91147..e4e7b63fe3 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -15209,6 +15209,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv) list_T *l; listitem_T *li; dict_T *d; + list_T *s = NULL; rettv->vval.v_number = -1; if (argvars[0].v_type != VAR_LIST) { @@ -15227,7 +15228,8 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv) return; } if (!(dict_find(d, (char_u *)"group", -1) != NULL - && dict_find(d, (char_u *)"pattern", -1) != NULL + && (dict_find(d, (char_u *)"pattern", -1) != NULL + || dict_find(d, (char_u *)"pos1", -1) != NULL) && dict_find(d, (char_u *)"priority", -1) != NULL && dict_find(d, (char_u *)"id", -1) != NULL)) { EMSG(_(e_invarg)); @@ -15239,11 +15241,47 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv) clear_matches(curwin); li = l->lv_first; while (li != NULL) { + int i = 0; + char_u buf[5]; + dictitem_T *di; d = li->li_tv.vval.v_dict; - match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE), - get_dict_string(d, (char_u *)"pattern", FALSE), - (int)get_dict_number(d, (char_u *)"priority"), - (int)get_dict_number(d, (char_u *)"id"), NULL); + + if (dict_find(d, (char_u *)"pattern", -1) == NULL) { + if (s == NULL) { + s = list_alloc(); + if (s == NULL) { + return; + } + } + + // match from matchaddpos() + for (i = 1; i < 9; ++i) { + snprintf((char *)buf, sizeof(buf), (char *)"pos%d", i); + if ((di = dict_find(d, (char_u *)buf, -1)) != NULL) { + if (di->di_tv.v_type != VAR_LIST) { + return; + } + + list_append_tv(s, &di->di_tv); + s->lv_refcount++; + } else { + break; + } + } + } + + if (i == 0) { + match_add(curwin, get_dict_string(d, (char_u *)"group", false), + get_dict_string(d, (char_u *)"pattern", false), + (int)get_dict_number(d, (char_u *)"priority"), + (int)get_dict_number(d, (char_u *)"id"), NULL); + } else { + match_add(curwin, get_dict_string(d, (char_u *)"group", false), + NULL, (int)get_dict_number(d, (char_u *)"priority"), + (int)get_dict_number(d, (char_u *)"id"), s); + list_unref(s); + s = NULL; + } li = li->li_next; } rettv->vval.v_number = 0; |