1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: When 'completefunc' opens a new window all kinds of errors follow.
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
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
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");
35 * Structure used to store one match for insert completion.
45 funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu;
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)
57 ! ins_compl_add_list(matchlist);
58 ! list_unref(matchlist);
60 #endif /* FEAT_COMPL_FUNC */
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)
71 + EMSG(_(e_complwin));
74 curwin->w_cursor = pos; /* restore the cursor position */
76 ! if (!equalpos(curwin->w_cursor, pos))
78 ! EMSG(_(e_compldel));
81 ! if (matchlist != NULL)
82 ! ins_compl_add_list(matchlist);
85 ! if (matchlist != NULL)
86 ! list_unref(matchlist);
88 #endif /* FEAT_COMPL_FUNC */
99 /* Call 'completefunc' or 'omnifunc' and get pattern length as a
104 args[0] = (char_u *)"1";
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)
112 + EMSG(_(e_complwin));
115 curwin->w_cursor = pos; /* restore the cursor position */
117 + if (!equalpos(curwin->w_cursor, pos))
119 + EMSG(_(e_compldel));
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
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
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 \
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
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
161 SCRIPTS32 = test50.out test70.out
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
169 SCRIPTS32 = test50.out test70.out
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
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
180 SCRIPTS32 = test50.out test70.out
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
188 SCRIPTS32 = test50.out test70.out
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
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
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 \
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
214 # Authors: Zoltan Arpadffy, <arpadffy@polarhome.com>
215 # Sandor Kopanyi, <sandor.kopanyi@mailbox.hu>
217 ! # Last change: 2010 Oct 20
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.
222 # Authors: Zoltan Arpadffy, <arpadffy@polarhome.com>
223 # Sandor Kopanyi, <sandor.kopanyi@mailbox.hu>
225 ! # Last change: 2010 Nov 10
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.
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
237 # Test 30: a problem around mac format - unknown reason
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
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
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
255 SCRIPTS_GUI = test16.out
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
263 SCRIPTS_GUI = test16.out
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
270 + Tests for completefunc/omnifunc. vim: set ft=vim :
273 + :"Test that nothing happens if the 'completefunc' opens
274 + :"a new window (no completion, no crash)
276 + :function! DummyCompleteOne(findstart, base)
281 + : return ['onedef', 'oneDEF']
284 + :setlocal completefunc=DummyCompleteOne
287 + :function! DummyCompleteTwo(findstart, base)
292 + : return ['twodef', 'twoDEF']
295 + :setlocal completefunc=DummyCompleteTwo
298 + :"Test that 'completefunc' works when it's OK.
299 + :function! DummyCompleteThree(findstart, base)
303 + : return ['threedef', 'threeDEF']
306 + :setlocal completefunc=DummyCompleteThree
308 + A
\18\15\ e\e:/^+++/,/^three/w! test.out
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
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
330 { /* Add new patch number below this line */
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
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 ///