summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.3.052
blob: be0691fa4405f7055f2f8646edd899d31d45eb0a (plain) (blame)
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
To: vim_dev@googlegroups.com
Subject: Patch 7.3.052
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.052
Problem:    When 'completefunc' opens a new window all kinds of errors follow.
	    (Xavier Deguillard)
Solution:   When 'completefunc' goes to another window or buffer and when it
	    deletes text abort completion.  Add a test for 'completefunc'.
Files:	    src/edit.c, src/testdir/Make_amiga.mak, src/testdir/Make_dos.mak,
	    src/testdir/Make_ming.mak, src/testdir/Make_os2.mak,
	    src/testdir/Make_vms.mms, src/testdir/Makefile,
	    src/testdir/test76.in, src/testdir/test76.ok


*** ../vim-7.3.051/src/edit.c	2010-08-15 21:57:25.000000000 +0200
--- src/edit.c	2010-11-10 16:50:12.000000000 +0100
***************
*** 58,63 ****
--- 58,67 ----
  };
  
  static char e_hitend[] = N_("Hit end of paragraph");
+ #ifdef FEAT_COMPL_FUNC
+ static char e_complwin[] = N_("E839: Completion function changed window");
+ static char e_compldel[] = N_("E840: Completion function deleted text");
+ #endif
  
  /*
   * Structure used to store one match for insert completion.
***************
*** 3833,3838 ****
--- 3837,3844 ----
      char_u	*args[2];
      char_u	*funcname;
      pos_T	pos;
+     win_T	*curwin_save;
+     buf_T	*curbuf_save;
  
      funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu;
      if (*funcname == NUL)
***************
*** 3843,3855 ****
      args[1] = base;
  
      pos = curwin->w_cursor;
      matchlist = call_func_retlist(funcname, 2, args, FALSE);
      curwin->w_cursor = pos;	/* restore the cursor position */
!     if (matchlist == NULL)
! 	return;
  
!     ins_compl_add_list(matchlist);
!     list_unref(matchlist);
  }
  #endif /* FEAT_COMPL_FUNC */
  
--- 3849,3875 ----
      args[1] = base;
  
      pos = curwin->w_cursor;
+     curwin_save = curwin;
+     curbuf_save = curbuf;
      matchlist = call_func_retlist(funcname, 2, args, FALSE);
+     if (curwin_save != curwin || curbuf_save != curbuf)
+     {
+ 	EMSG(_(e_complwin));
+ 	goto theend;
+     }
      curwin->w_cursor = pos;	/* restore the cursor position */
!     check_cursor();
!     if (!equalpos(curwin->w_cursor, pos))
!     {
! 	EMSG(_(e_compldel));
! 	goto theend;
!     }
!     if (matchlist != NULL)
! 	ins_compl_add_list(matchlist);
  
! theend:
!     if (matchlist != NULL)
! 	list_unref(matchlist);
  }
  #endif /* FEAT_COMPL_FUNC */
  
***************
*** 4994,4999 ****
--- 5014,5021 ----
  	    int		col;
  	    char_u	*funcname;
  	    pos_T	pos;
+ 	    win_T	*curwin_save;
+ 	    buf_T	*curbuf_save;
  
  	    /* Call 'completefunc' or 'omnifunc' and get pattern length as a
  	     * string */
***************
*** 5009,5016 ****
--- 5031,5051 ----
  	    args[0] = (char_u *)"1";
  	    args[1] = NULL;
  	    pos = curwin->w_cursor;
+ 	    curwin_save = curwin;
+ 	    curbuf_save = curbuf;
  	    col = call_func_retnr(funcname, 2, args, FALSE);
+ 	    if (curwin_save != curwin || curbuf_save != curbuf)
+ 	    {
+ 		EMSG(_(e_complwin));
+ 		return FAIL;
+ 	    }
  	    curwin->w_cursor = pos;	/* restore the cursor position */
+ 	    check_cursor();
+ 	    if (!equalpos(curwin->w_cursor, pos))
+ 	    {
+ 		EMSG(_(e_compldel));
+ 		return FAIL;
+ 	    }
  
  	    if (col < 0)
  		col = curs_col;
*** ../vim-7.3.051/src/testdir/Make_amiga.mak	2010-10-27 18:36:32.000000000 +0200
--- src/testdir/Make_amiga.mak	2010-11-10 15:48:30.000000000 +0100
***************
*** 27,33 ****
  		test56.out test57.out test58.out test59.out test60.out \
  		test61.out test62.out test63.out test64.out test65.out \
  		test66.out test67.out test68.out test69.out test70.out \
! 		test71.out test72.out test73.out test74.out test75.out
  
  .SUFFIXES: .in .out
  
--- 27,34 ----
  		test56.out test57.out test58.out test59.out test60.out \
  		test61.out test62.out test63.out test64.out test65.out \
  		test66.out test67.out test68.out test69.out test70.out \
! 		test71.out test72.out test73.out test74.out test75.out \
! 		test76.out
  
  .SUFFIXES: .in .out
  
***************
*** 122,124 ****
--- 123,126 ----
  test73.out: test73.in
  test74.out: test74.in
  test75.out: test75.in
+ test76.out: test76.in
*** ../vim-7.3.051/src/testdir/Make_dos.mak	2010-10-27 18:36:32.000000000 +0200
--- src/testdir/Make_dos.mak	2010-11-10 15:48:38.000000000 +0100
***************
*** 28,34 ****
  		test37.out test38.out test39.out test40.out test41.out \
  		test42.out test52.out test65.out test66.out test67.out \
  		test68.out test69.out test71.out test72.out test73.out \
! 		test74.out test75.out
  
  SCRIPTS32 =	test50.out test70.out
  
--- 28,34 ----
  		test37.out test38.out test39.out test40.out test41.out \
  		test42.out test52.out test65.out test66.out test67.out \
  		test68.out test69.out test71.out test72.out test73.out \
! 		test74.out test75.out test76.out
  
  SCRIPTS32 =	test50.out test70.out
  
*** ../vim-7.3.051/src/testdir/Make_ming.mak	2010-10-27 18:36:32.000000000 +0200
--- src/testdir/Make_ming.mak	2010-11-10 15:48:53.000000000 +0100
***************
*** 48,54 ****
  		test37.out test38.out test39.out test40.out test41.out \
  		test42.out test52.out test65.out test66.out test67.out \
  		test68.out test69.out test71.out test72.out test73.out \
! 		test74.out test75.out
  
  SCRIPTS32 =	test50.out test70.out
  
--- 48,54 ----
  		test37.out test38.out test39.out test40.out test41.out \
  		test42.out test52.out test65.out test66.out test67.out \
  		test68.out test69.out test71.out test72.out test73.out \
! 		test74.out test75.out test76.out
  
  SCRIPTS32 =	test50.out test70.out
  
*** ../vim-7.3.051/src/testdir/Make_os2.mak	2010-10-27 18:36:32.000000000 +0200
--- src/testdir/Make_os2.mak	2010-11-10 15:49:10.000000000 +0100
***************
*** 27,33 ****
  		test56.out test57.out test58.out test59.out test60.out \
  		test61.out test62.out test63.out test64.out test65.out \
  		test66.out test67.out test68.out test69.out test70.out \
! 		test71.out test72.out test73.out test74.out test75.out
  
  .SUFFIXES: .in .out
  
--- 27,34 ----
  		test56.out test57.out test58.out test59.out test60.out \
  		test61.out test62.out test63.out test64.out test65.out \
  		test66.out test67.out test68.out test69.out test70.out \
! 		test71.out test72.out test73.out test74.out test75.out \
! 		test76.out
  
  .SUFFIXES: .in .out
  
*** ../vim-7.3.051/src/testdir/Make_vms.mms	2010-10-27 18:36:32.000000000 +0200
--- src/testdir/Make_vms.mms	2010-11-10 15:49:32.000000000 +0100
***************
*** 4,10 ****
  # Authors:	Zoltan Arpadffy, <arpadffy@polarhome.com>
  #		Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
  #
! # Last change:  2010 Oct 20
  #
  # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
  # Edit the lines in the Configuration section below to select.
--- 4,10 ----
  # Authors:	Zoltan Arpadffy, <arpadffy@polarhome.com>
  #		Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
  #
! # Last change:  2010 Nov 10
  #
  # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
  # Edit the lines in the Configuration section below to select.
***************
*** 74,80 ****
  	 test56.out test57.out test60.out \
  	 test61.out test62.out test63.out test64.out test65.out \
  	 test66.out test67.out test68.out test69.out \
! 	 test71.out test72.out test74.out test75.out
  
  # Known problems:
  # Test 30: a problem around mac format - unknown reason
--- 74,80 ----
  	 test56.out test57.out test60.out \
  	 test61.out test62.out test63.out test64.out test65.out \
  	 test66.out test67.out test68.out test69.out \
! 	 test71.out test72.out test74.out test75.out test76.out
  
  # Known problems:
  # Test 30: a problem around mac format - unknown reason
*** ../vim-7.3.051/src/testdir/Makefile	2010-10-27 18:36:32.000000000 +0200
--- src/testdir/Makefile	2010-11-10 15:47:32.000000000 +0100
***************
*** 25,31 ****
  		test59.out test60.out test61.out test62.out test63.out \
  		test64.out test65.out test66.out test67.out test68.out \
  		test69.out test70.out test71.out test72.out test73.out \
! 		test74.out test75.out
  
  SCRIPTS_GUI = test16.out
  
--- 25,31 ----
  		test59.out test60.out test61.out test62.out test63.out \
  		test64.out test65.out test66.out test67.out test68.out \
  		test69.out test70.out test71.out test72.out test73.out \
! 		test74.out test75.out test76.out
  
  SCRIPTS_GUI = test16.out
  
*** ../vim-7.3.051/src/testdir/test76.in	2010-11-10 16:51:45.000000000 +0100
--- src/testdir/test76.in	2010-11-10 16:38:45.000000000 +0100
***************
*** 0 ****
--- 1,46 ----
+ Tests for completefunc/omnifunc. vim: set ft=vim :
+ 
+ STARTTEST
+ :"Test that nothing happens if the 'completefunc' opens
+ :"a new window (no completion, no crash)
+ :so small.vim
+ :function! DummyCompleteOne(findstart, base)
+ :  if a:findstart
+ :    return 0
+ :  else
+ :    wincmd n
+ :    return ['onedef', 'oneDEF']
+ :  endif
+ :endfunction
+ :setlocal completefunc=DummyCompleteOne
+ /^one
+ A:q!
+ :function! DummyCompleteTwo(findstart, base)
+ :  if a:findstart
+ :    wincmd n
+ :    return 0
+ :  else
+ :    return ['twodef', 'twoDEF']
+ :  endif
+ :endfunction
+ :setlocal completefunc=DummyCompleteTwo
+ /^two
+ A:q!
+ :"Test that 'completefunc' works when it's OK.
+ :function! DummyCompleteThree(findstart, base)
+ :  if a:findstart
+ :    return 0
+ :  else
+ :    return ['threedef', 'threeDEF']
+ :  endif
+ :endfunction
+ :setlocal completefunc=DummyCompleteThree
+ /^three
+ A:/^+++/,/^three/w! test.out
+ :qa!
+ ENDTEST
+ 
+ +++
+ one
+ two
+ three
*** ../vim-7.3.051/src/testdir/test76.ok	2010-11-10 16:51:45.000000000 +0100
--- src/testdir/test76.ok	2010-11-10 16:38:58.000000000 +0100
***************
*** 0 ****
--- 1,4 ----
+ +++
+ 
+ two
+ threeDEF
*** ../vim-7.3.051/src/version.c	2010-11-10 15:37:00.000000000 +0100
--- src/version.c	2010-11-10 16:40:29.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     52,
  /**/

-- 
BRIDGEKEEPER: What is the air-speed velocity of an unladen swallow?
ARTHUR:       What do you mean?  An African or European swallow?
BRIDGEKEEPER: Er ...  I don't know that ... Aaaaarrrrrrggghhh!
   BRIDGEKEEPER is cast into the gorge.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///