]>
Commit | Line | Data |
---|---|---|
c9934a4a ER |
1 | To: vim_dev@googlegroups.com |
2 | Subject: Patch 7.3.052 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.052 | |
11 | Problem: When 'completefunc' opens a new window all kinds of errors follow. | |
12 | (Xavier Deguillard) | |
13 | Solution: When 'completefunc' goes to another window or buffer and when it | |
14 | deletes text abort completion. Add a test for 'completefunc'. | |
15 | Files: src/edit.c, src/testdir/Make_amiga.mak, src/testdir/Make_dos.mak, | |
16 | src/testdir/Make_ming.mak, src/testdir/Make_os2.mak, | |
17 | src/testdir/Make_vms.mms, src/testdir/Makefile, | |
18 | src/testdir/test76.in, src/testdir/test76.ok | |
19 | ||
20 | ||
21 | *** ../vim-7.3.051/src/edit.c 2010-08-15 21:57:25.000000000 +0200 | |
22 | --- src/edit.c 2010-11-10 16:50:12.000000000 +0100 | |
23 | *************** | |
24 | *** 58,63 **** | |
25 | --- 58,67 ---- | |
26 | }; | |
27 | ||
28 | static char e_hitend[] = N_("Hit end of paragraph"); | |
29 | + #ifdef FEAT_COMPL_FUNC | |
30 | + static char e_complwin[] = N_("E839: Completion function changed window"); | |
31 | + static char e_compldel[] = N_("E840: Completion function deleted text"); | |
32 | + #endif | |
33 | ||
34 | /* | |
35 | * Structure used to store one match for insert completion. | |
36 | *************** | |
37 | *** 3833,3838 **** | |
38 | --- 3837,3844 ---- | |
39 | char_u *args[2]; | |
40 | char_u *funcname; | |
41 | pos_T pos; | |
42 | + win_T *curwin_save; | |
43 | + buf_T *curbuf_save; | |
44 | ||
45 | funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu; | |
46 | if (*funcname == NUL) | |
47 | *************** | |
48 | *** 3843,3855 **** | |
49 | args[1] = base; | |
50 | ||
51 | pos = curwin->w_cursor; | |
52 | matchlist = call_func_retlist(funcname, 2, args, FALSE); | |
53 | curwin->w_cursor = pos; /* restore the cursor position */ | |
54 | ! if (matchlist == NULL) | |
55 | ! return; | |
56 | ||
57 | ! ins_compl_add_list(matchlist); | |
58 | ! list_unref(matchlist); | |
59 | } | |
60 | #endif /* FEAT_COMPL_FUNC */ | |
61 | ||
62 | --- 3849,3875 ---- | |
63 | args[1] = base; | |
64 | ||
65 | pos = curwin->w_cursor; | |
66 | + curwin_save = curwin; | |
67 | + curbuf_save = curbuf; | |
68 | matchlist = call_func_retlist(funcname, 2, args, FALSE); | |
69 | + if (curwin_save != curwin || curbuf_save != curbuf) | |
70 | + { | |
71 | + EMSG(_(e_complwin)); | |
72 | + goto theend; | |
73 | + } | |
74 | curwin->w_cursor = pos; /* restore the cursor position */ | |
75 | ! check_cursor(); | |
76 | ! if (!equalpos(curwin->w_cursor, pos)) | |
77 | ! { | |
78 | ! EMSG(_(e_compldel)); | |
79 | ! goto theend; | |
80 | ! } | |
81 | ! if (matchlist != NULL) | |
82 | ! ins_compl_add_list(matchlist); | |
83 | ||
84 | ! theend: | |
85 | ! if (matchlist != NULL) | |
86 | ! list_unref(matchlist); | |
87 | } | |
88 | #endif /* FEAT_COMPL_FUNC */ | |
89 | ||
90 | *************** | |
91 | *** 4994,4999 **** | |
92 | --- 5014,5021 ---- | |
93 | int col; | |
94 | char_u *funcname; | |
95 | pos_T pos; | |
96 | + win_T *curwin_save; | |
97 | + buf_T *curbuf_save; | |
98 | ||
99 | /* Call 'completefunc' or 'omnifunc' and get pattern length as a | |
100 | * string */ | |
101 | *************** | |
102 | *** 5009,5016 **** | |
103 | --- 5031,5051 ---- | |
104 | args[0] = (char_u *)"1"; | |
105 | args[1] = NULL; | |
106 | pos = curwin->w_cursor; | |
107 | + curwin_save = curwin; | |
108 | + curbuf_save = curbuf; | |
109 | col = call_func_retnr(funcname, 2, args, FALSE); | |
110 | + if (curwin_save != curwin || curbuf_save != curbuf) | |
111 | + { | |
112 | + EMSG(_(e_complwin)); | |
113 | + return FAIL; | |
114 | + } | |
115 | curwin->w_cursor = pos; /* restore the cursor position */ | |
116 | + check_cursor(); | |
117 | + if (!equalpos(curwin->w_cursor, pos)) | |
118 | + { | |
119 | + EMSG(_(e_compldel)); | |
120 | + return FAIL; | |
121 | + } | |
122 | ||
123 | if (col < 0) | |
124 | col = curs_col; | |
125 | *** ../vim-7.3.051/src/testdir/Make_amiga.mak 2010-10-27 18:36:32.000000000 +0200 | |
126 | --- src/testdir/Make_amiga.mak 2010-11-10 15:48:30.000000000 +0100 | |
127 | *************** | |
128 | *** 27,33 **** | |
129 | test56.out test57.out test58.out test59.out test60.out \ | |
130 | test61.out test62.out test63.out test64.out test65.out \ | |
131 | test66.out test67.out test68.out test69.out test70.out \ | |
132 | ! test71.out test72.out test73.out test74.out test75.out | |
133 | ||
134 | .SUFFIXES: .in .out | |
135 | ||
136 | --- 27,34 ---- | |
137 | test56.out test57.out test58.out test59.out test60.out \ | |
138 | test61.out test62.out test63.out test64.out test65.out \ | |
139 | test66.out test67.out test68.out test69.out test70.out \ | |
140 | ! test71.out test72.out test73.out test74.out test75.out \ | |
141 | ! test76.out | |
142 | ||
143 | .SUFFIXES: .in .out | |
144 | ||
145 | *************** | |
146 | *** 122,124 **** | |
147 | --- 123,126 ---- | |
148 | test73.out: test73.in | |
149 | test74.out: test74.in | |
150 | test75.out: test75.in | |
151 | + test76.out: test76.in | |
152 | *** ../vim-7.3.051/src/testdir/Make_dos.mak 2010-10-27 18:36:32.000000000 +0200 | |
153 | --- src/testdir/Make_dos.mak 2010-11-10 15:48:38.000000000 +0100 | |
154 | *************** | |
155 | *** 28,34 **** | |
156 | test37.out test38.out test39.out test40.out test41.out \ | |
157 | test42.out test52.out test65.out test66.out test67.out \ | |
158 | test68.out test69.out test71.out test72.out test73.out \ | |
159 | ! test74.out test75.out | |
160 | ||
161 | SCRIPTS32 = test50.out test70.out | |
162 | ||
163 | --- 28,34 ---- | |
164 | test37.out test38.out test39.out test40.out test41.out \ | |
165 | test42.out test52.out test65.out test66.out test67.out \ | |
166 | test68.out test69.out test71.out test72.out test73.out \ | |
167 | ! test74.out test75.out test76.out | |
168 | ||
169 | SCRIPTS32 = test50.out test70.out | |
170 | ||
171 | *** ../vim-7.3.051/src/testdir/Make_ming.mak 2010-10-27 18:36:32.000000000 +0200 | |
172 | --- src/testdir/Make_ming.mak 2010-11-10 15:48:53.000000000 +0100 | |
173 | *************** | |
174 | *** 48,54 **** | |
175 | test37.out test38.out test39.out test40.out test41.out \ | |
176 | test42.out test52.out test65.out test66.out test67.out \ | |
177 | test68.out test69.out test71.out test72.out test73.out \ | |
178 | ! test74.out test75.out | |
179 | ||
180 | SCRIPTS32 = test50.out test70.out | |
181 | ||
182 | --- 48,54 ---- | |
183 | test37.out test38.out test39.out test40.out test41.out \ | |
184 | test42.out test52.out test65.out test66.out test67.out \ | |
185 | test68.out test69.out test71.out test72.out test73.out \ | |
186 | ! test74.out test75.out test76.out | |
187 | ||
188 | SCRIPTS32 = test50.out test70.out | |
189 | ||
190 | *** ../vim-7.3.051/src/testdir/Make_os2.mak 2010-10-27 18:36:32.000000000 +0200 | |
191 | --- src/testdir/Make_os2.mak 2010-11-10 15:49:10.000000000 +0100 | |
192 | *************** | |
193 | *** 27,33 **** | |
194 | test56.out test57.out test58.out test59.out test60.out \ | |
195 | test61.out test62.out test63.out test64.out test65.out \ | |
196 | test66.out test67.out test68.out test69.out test70.out \ | |
197 | ! test71.out test72.out test73.out test74.out test75.out | |
198 | ||
199 | .SUFFIXES: .in .out | |
200 | ||
201 | --- 27,34 ---- | |
202 | test56.out test57.out test58.out test59.out test60.out \ | |
203 | test61.out test62.out test63.out test64.out test65.out \ | |
204 | test66.out test67.out test68.out test69.out test70.out \ | |
205 | ! test71.out test72.out test73.out test74.out test75.out \ | |
206 | ! test76.out | |
207 | ||
208 | .SUFFIXES: .in .out | |
209 | ||
210 | *** ../vim-7.3.051/src/testdir/Make_vms.mms 2010-10-27 18:36:32.000000000 +0200 | |
211 | --- src/testdir/Make_vms.mms 2010-11-10 15:49:32.000000000 +0100 | |
212 | *************** | |
213 | *** 4,10 **** | |
214 | # Authors: Zoltan Arpadffy, <arpadffy@polarhome.com> | |
215 | # Sandor Kopanyi, <sandor.kopanyi@mailbox.hu> | |
216 | # | |
217 | ! # Last change: 2010 Oct 20 | |
218 | # | |
219 | # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64. | |
220 | # Edit the lines in the Configuration section below to select. | |
221 | --- 4,10 ---- | |
222 | # Authors: Zoltan Arpadffy, <arpadffy@polarhome.com> | |
223 | # Sandor Kopanyi, <sandor.kopanyi@mailbox.hu> | |
224 | # | |
225 | ! # Last change: 2010 Nov 10 | |
226 | # | |
227 | # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64. | |
228 | # Edit the lines in the Configuration section below to select. | |
229 | *************** | |
230 | *** 74,80 **** | |
231 | test56.out test57.out test60.out \ | |
232 | test61.out test62.out test63.out test64.out test65.out \ | |
233 | test66.out test67.out test68.out test69.out \ | |
234 | ! test71.out test72.out test74.out test75.out | |
235 | ||
236 | # Known problems: | |
237 | # Test 30: a problem around mac format - unknown reason | |
238 | --- 74,80 ---- | |
239 | test56.out test57.out test60.out \ | |
240 | test61.out test62.out test63.out test64.out test65.out \ | |
241 | test66.out test67.out test68.out test69.out \ | |
242 | ! test71.out test72.out test74.out test75.out test76.out | |
243 | ||
244 | # Known problems: | |
245 | # Test 30: a problem around mac format - unknown reason | |
246 | *** ../vim-7.3.051/src/testdir/Makefile 2010-10-27 18:36:32.000000000 +0200 | |
247 | --- src/testdir/Makefile 2010-11-10 15:47:32.000000000 +0100 | |
248 | *************** | |
249 | *** 25,31 **** | |
250 | test59.out test60.out test61.out test62.out test63.out \ | |
251 | test64.out test65.out test66.out test67.out test68.out \ | |
252 | test69.out test70.out test71.out test72.out test73.out \ | |
253 | ! test74.out test75.out | |
254 | ||
255 | SCRIPTS_GUI = test16.out | |
256 | ||
257 | --- 25,31 ---- | |
258 | test59.out test60.out test61.out test62.out test63.out \ | |
259 | test64.out test65.out test66.out test67.out test68.out \ | |
260 | test69.out test70.out test71.out test72.out test73.out \ | |
261 | ! test74.out test75.out test76.out | |
262 | ||
263 | SCRIPTS_GUI = test16.out | |
264 | ||
265 | *** ../vim-7.3.051/src/testdir/test76.in 2010-11-10 16:51:45.000000000 +0100 | |
266 | --- src/testdir/test76.in 2010-11-10 16:38:45.000000000 +0100 | |
267 | *************** | |
268 | *** 0 **** | |
269 | --- 1,46 ---- | |
270 | + Tests for completefunc/omnifunc. vim: set ft=vim : | |
271 | + | |
272 | + STARTTEST | |
273 | + :"Test that nothing happens if the 'completefunc' opens | |
274 | + :"a new window (no completion, no crash) | |
275 | + :so small.vim | |
276 | + :function! DummyCompleteOne(findstart, base) | |
277 | + : if a:findstart | |
278 | + : return 0 | |
279 | + : else | |
280 | + : wincmd n | |
281 | + : return ['onedef', 'oneDEF'] | |
282 | + : endif | |
283 | + :endfunction | |
284 | + :setlocal completefunc=DummyCompleteOne | |
285 | + /^one | |
286 | + A\18\15\ e\e:q! | |
287 | + :function! DummyCompleteTwo(findstart, base) | |
288 | + : if a:findstart | |
289 | + : wincmd n | |
290 | + : return 0 | |
291 | + : else | |
292 | + : return ['twodef', 'twoDEF'] | |
293 | + : endif | |
294 | + :endfunction | |
295 | + :setlocal completefunc=DummyCompleteTwo | |
296 | + /^two | |
297 | + A\18\15\ e\e:q! | |
298 | + :"Test that 'completefunc' works when it's OK. | |
299 | + :function! DummyCompleteThree(findstart, base) | |
300 | + : if a:findstart | |
301 | + : return 0 | |
302 | + : else | |
303 | + : return ['threedef', 'threeDEF'] | |
304 | + : endif | |
305 | + :endfunction | |
306 | + :setlocal completefunc=DummyCompleteThree | |
307 | + /^three | |
308 | + A\18\15\ e\e:/^+++/,/^three/w! test.out | |
309 | + :qa! | |
310 | + ENDTEST | |
311 | + | |
312 | + +++ | |
313 | + one | |
314 | + two | |
315 | + three | |
316 | *** ../vim-7.3.051/src/testdir/test76.ok 2010-11-10 16:51:45.000000000 +0100 | |
317 | --- src/testdir/test76.ok 2010-11-10 16:38:58.000000000 +0100 | |
318 | *************** | |
319 | *** 0 **** | |
320 | --- 1,4 ---- | |
321 | + +++ | |
322 | + | |
323 | + two | |
324 | + threeDEF | |
325 | *** ../vim-7.3.051/src/version.c 2010-11-10 15:37:00.000000000 +0100 | |
326 | --- src/version.c 2010-11-10 16:40:29.000000000 +0100 | |
327 | *************** | |
328 | *** 716,717 **** | |
329 | --- 716,719 ---- | |
330 | { /* Add new patch number below this line */ | |
331 | + /**/ | |
332 | + 52, | |
333 | /**/ | |
334 | ||
335 | -- | |
336 | BRIDGEKEEPER: What is the air-speed velocity of an unladen swallow? | |
337 | ARTHUR: What do you mean? An African or European swallow? | |
338 | BRIDGEKEEPER: Er ... I don't know that ... Aaaaarrrrrrggghhh! | |
339 | BRIDGEKEEPER is cast into the gorge. | |
340 | "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD | |
341 | ||
342 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
343 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
344 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
345 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |