1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0218
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0218
Problem: Cannot add matches to another window. (Qiming Zhao)
Solution: Add the "window" argument to matchadd() and matchaddpos().
(closes #3260)
Files: src/evalfunc.c, runtime/doc/eval.txt, src/testdir/test_match.vim
*** ../vim-8.1.0217/src/evalfunc.c 2018-07-27 22:08:54.084115114 +0200
--- src/evalfunc.c 2018-07-28 16:38:54.045497084 +0200
***************
*** 7988,7993 ****
--- 7988,8023 ----
find_some_match(argvars, rettv, MATCH_MATCH);
}
+ #ifdef FEAT_SEARCH_EXTRA
+ static int
+ matchadd_dict_arg(typval_T *tv, char_u **conceal_char, win_T **win)
+ {
+ dictitem_T *di;
+
+ if (tv->v_type != VAR_DICT)
+ {
+ EMSG(_(e_dictreq));
+ return FAIL;
+ }
+
+ if (dict_find(tv->vval.v_dict, (char_u *)"conceal", -1) != NULL)
+ *conceal_char = get_dict_string(tv->vval.v_dict,
+ (char_u *)"conceal", FALSE);
+
+ if ((di = dict_find(tv->vval.v_dict, (char_u *)"window", -1)) != NULL)
+ {
+ *win = find_win_by_nr(&di->di_tv, NULL);
+ if (*win == NULL)
+ {
+ EMSG(_("E957: Invalid window number"));
+ return FAIL;
+ }
+ }
+
+ return OK;
+ }
+ #endif
+
/*
* "matchadd()" function
*/
***************
*** 8002,8007 ****
--- 8032,8038 ----
int id = -1;
int error = FALSE;
char_u *conceal_char = NULL;
+ win_T *win = curwin;
rettv->vval.v_number = -1;
***************
*** 8013,8030 ****
if (argvars[3].v_type != VAR_UNKNOWN)
{
id = (int)get_tv_number_chk(&argvars[3], &error);
! if (argvars[4].v_type != VAR_UNKNOWN)
! {
! if (argvars[4].v_type != VAR_DICT)
! {
! EMSG(_(e_dictreq));
! return;
! }
! if (dict_find(argvars[4].vval.v_dict,
! (char_u *)"conceal", -1) != NULL)
! conceal_char = get_dict_string(argvars[4].vval.v_dict,
! (char_u *)"conceal", FALSE);
! }
}
}
if (error == TRUE)
--- 8044,8052 ----
if (argvars[3].v_type != VAR_UNKNOWN)
{
id = (int)get_tv_number_chk(&argvars[3], &error);
! if (argvars[4].v_type != VAR_UNKNOWN
! && matchadd_dict_arg(&argvars[4], &conceal_char, &win) == FAIL)
! return;
}
}
if (error == TRUE)
***************
*** 8035,8041 ****
return;
}
! rettv->vval.v_number = match_add(curwin, grp, pat, prio, id, NULL,
conceal_char);
#endif
}
--- 8057,8063 ----
return;
}
! rettv->vval.v_number = match_add(win, grp, pat, prio, id, NULL,
conceal_char);
#endif
}
***************
*** 8054,8059 ****
--- 8076,8082 ----
int error = FALSE;
list_T *l;
char_u *conceal_char = NULL;
+ win_T *win = curwin;
rettv->vval.v_number = -1;
***************
*** 8076,8093 ****
if (argvars[3].v_type != VAR_UNKNOWN)
{
id = (int)get_tv_number_chk(&argvars[3], &error);
! if (argvars[4].v_type != VAR_UNKNOWN)
! {
! if (argvars[4].v_type != VAR_DICT)
! {
! EMSG(_(e_dictreq));
! return;
! }
! if (dict_find(argvars[4].vval.v_dict,
! (char_u *)"conceal", -1) != NULL)
! conceal_char = get_dict_string(argvars[4].vval.v_dict,
! (char_u *)"conceal", FALSE);
! }
}
}
if (error == TRUE)
--- 8099,8108 ----
if (argvars[3].v_type != VAR_UNKNOWN)
{
id = (int)get_tv_number_chk(&argvars[3], &error);
!
! if (argvars[4].v_type != VAR_UNKNOWN
! && matchadd_dict_arg(&argvars[4], &conceal_char, &win) == FAIL)
! return;
}
}
if (error == TRUE)
***************
*** 8100,8106 ****
return;
}
! rettv->vval.v_number = match_add(curwin, group, NULL, prio, id, l,
conceal_char);
#endif
}
--- 8115,8121 ----
return;
}
! rettv->vval.v_number = match_add(win, group, NULL, prio, id, l,
conceal_char);
#endif
}
*** ../vim-8.1.0217/runtime/doc/eval.txt 2018-07-15 17:01:06.361425488 +0200
--- runtime/doc/eval.txt 2018-07-28 16:54:21.839764726 +0200
***************
*** 6015,6021 ****
the pattern. 'smartcase' is NOT used. The matching is always
done like 'magic' is set and 'cpoptions' is empty.
! *matchadd()* *E798* *E799* *E801*
matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
Defines a pattern to be highlighted in the current window (a
"match"). It will be highlighted with {group}. Returns an
--- 6016,6022 ----
the pattern. 'smartcase' is NOT used. The matching is always
done like 'magic' is set and 'cpoptions' is empty.
! *matchadd()* *E798* *E799* *E801* *E957*
matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
Defines a pattern to be highlighted in the current window (a
"match"). It will be highlighted with {group}. Returns an
***************
*** 6054,6059 ****
--- 6055,6062 ----
conceal Special character to show instead of the
match (only for |hl-Conceal| highlighted
matches, see |:syn-cchar|)
+ window Instead of the current window use the
+ window with this number or window ID.
The number of matches is not limited, as it is the case with
the |:match| commands.
*** ../vim-8.1.0217/src/testdir/test_match.vim 2017-09-14 14:16:37.000000000 +0200
--- src/testdir/test_match.vim 2018-07-28 16:51:59.280637174 +0200
***************
*** 192,197 ****
--- 192,219 ----
set hlsearch&
endfunc
+ func Test_matchaddpos_otherwin()
+ syntax on
+ new
+ call setline(1, ['12345', 'NP'])
+ let winid = win_getid()
+
+ wincmd w
+ call matchadd('Search', '4', 10, -1, {'window': winid})
+ call matchaddpos('Error', [[1,2], [2,2]], 10, -1, {'window': winid})
+ redraw!
+ call assert_notequal(screenattr(1,2), 0)
+ call assert_notequal(screenattr(1,4), 0)
+ call assert_notequal(screenattr(2,2), 0)
+ call assert_equal(screenattr(1,2), screenattr(2,2))
+ call assert_notequal(screenattr(1,2), screenattr(1,4))
+
+ wincmd w
+ bwipe!
+ call clearmatches()
+ syntax off
+ endfunc
+
func Test_matchaddpos_using_negative_priority()
set hlsearch
*** ../vim-8.1.0217/src/version.c 2018-07-28 16:14:26.131040141 +0200
--- src/version.c 2018-07-28 16:40:26.416917394 +0200
***************
*** 800,801 ****
--- 800,803 ----
{ /* Add new patch number below this line */
+ /**/
+ 218,
/**/
--
'I generally avoid temptation unless I can't resist it."
-- Mae West
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|