summaryrefslogtreecommitdiffstats
path: root/gvim/vim-7.2/7.2.301
blob: e63cc088a9e2f7bf809ddf89564094bf3a2cbf3c (plain)
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
To: vim-dev@vim.org
Subject: Patch 7.2.301
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

NOTE: some mail and patch programs may have a problem with the non-ASCII
characters in this patch.  You can fetch the patch from
ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.301  and/or fetch the updated
files from CVS.  http://www.vim.org/cvs.php


Patch 7.2.301
Problem:    Formatting is wrong when 'tw' is set to a small value.
Solution:   Fix it and add tests.  Also fix behavior of "1" in 'fo'. (Yukihiro
	    Nakadaira)
Files:	    src/edit.c, src/testdir/Makefile, src/testdir/test68.in,
	    src/testdir/test68.ok, src/testdir/test69.in,
	    src/testdir/test69.ok


*** ../vim-7.2.300/src/edit.c	2009-11-11 13:22:32.000000000 +0100
--- src/edit.c	2009-11-17 15:34:47.000000000 +0100
***************
*** 181,187 ****
  static void ins_ctrl_v __ARGS((void));
  static void undisplay_dollar __ARGS((void));
  static void insert_special __ARGS((int, int, int));
! static void internal_format __ARGS((int textwidth, int second_indent, int flags, int format_only));
  static void check_auto_format __ARGS((int));
  static void redo_literal __ARGS((int c));
  static void start_arrow __ARGS((pos_T *end_insert_pos));
--- 181,187 ----
  static void ins_ctrl_v __ARGS((void));
  static void undisplay_dollar __ARGS((void));
  static void insert_special __ARGS((int, int, int));
! static void internal_format __ARGS((int textwidth, int second_indent, int flags, int format_only, int c));
  static void check_auto_format __ARGS((int));
  static void redo_literal __ARGS((int c));
  static void start_arrow __ARGS((pos_T *end_insert_pos));
***************
*** 2164,2170 ****
      int		i, c;
      int		actual_len;		/* Take multi-byte characters */
      int		actual_compl_length;	/* into account. */
!     int		*wca;		        /* Wide character array. */
      int		has_lower = FALSE;
      int		was_letter = FALSE;
  
--- 2164,2170 ----
      int		i, c;
      int		actual_len;		/* Take multi-byte characters */
      int		actual_compl_length;	/* into account. */
!     int		*wca;			/* Wide character array. */
      int		has_lower = FALSE;
      int		was_letter = FALSE;
  
***************
*** 5558,5564 ****
  	}
  	if (do_internal)
  #endif
! 	    internal_format(textwidth, second_indent, flags, c == NUL);
      }
  
      if (c == NUL)	    /* only formatting was wanted */
--- 5558,5564 ----
  	}
  	if (do_internal)
  #endif
! 	    internal_format(textwidth, second_indent, flags, c == NUL, c);
      }
  
      if (c == NUL)	    /* only formatting was wanted */
***************
*** 5738,5748 ****
   * Format text at the current insert position.
   */
      static void
! internal_format(textwidth, second_indent, flags, format_only)
      int		textwidth;
      int		second_indent;
      int		flags;
      int		format_only;
  {
      int		cc;
      int		save_char = NUL;
--- 5738,5749 ----
   * Format text at the current insert position.
   */
      static void
! internal_format(textwidth, second_indent, flags, format_only, c)
      int		textwidth;
      int		second_indent;
      int		flags;
      int		format_only;
+     int		c; /* character to be inserted (can be NUL) */
  {
      int		cc;
      int		save_char = NUL;
***************
*** 5763,5769 ****
       * When 'ai' is off we don't want a space under the cursor to be
       * deleted.  Replace it with an 'x' temporarily.
       */
!     if (!curbuf->b_p_ai)
      {
  	cc = gchar_cursor();
  	if (vim_iswhite(cc))
--- 5764,5774 ----
       * When 'ai' is off we don't want a space under the cursor to be
       * deleted.  Replace it with an 'x' temporarily.
       */
!     if (!curbuf->b_p_ai
! #ifdef FEAT_VREPLACE
! 	    && !(State & VREPLACE_FLAG)
! #endif
! 	    )
      {
  	cc = gchar_cursor();
  	if (vim_iswhite(cc))
***************
*** 5789,5797 ****
  	char_u	*saved_text = NULL;
  #endif
  	colnr_T	col;
  
! 	virtcol = get_nolist_virtcol();
! 	if (virtcol < (colnr_T)textwidth)
  	    break;
  
  #ifdef FEAT_COMMENTS
--- 5794,5804 ----
  	char_u	*saved_text = NULL;
  #endif
  	colnr_T	col;
+ 	colnr_T	end_col;
  
! 	virtcol = get_nolist_virtcol()
! 		+ char2cells(c != NUL ? c : gchar_cursor());
! 	if (virtcol <= (colnr_T)textwidth)
  	    break;
  
  #ifdef FEAT_COMMENTS
***************
*** 5831,5842 ****
  	coladvance((colnr_T)textwidth);
  	wantcol = curwin->w_cursor.col;
  
! 	curwin->w_cursor.col = startcol - 1;
! #ifdef FEAT_MBYTE
! 	/* Correct cursor for multi-byte character. */
! 	if (has_mbyte)
! 	    mb_adjust_cursor();
! #endif
  	foundcol = 0;
  
  	/*
--- 5838,5844 ----
  	coladvance((colnr_T)textwidth);
  	wantcol = curwin->w_cursor.col;
  
! 	curwin->w_cursor.col = startcol;
  	foundcol = 0;
  
  	/*
***************
*** 5847,5857 ****
  		    || curwin->w_cursor.lnum != Insstart.lnum
  		    || curwin->w_cursor.col >= Insstart.col)
  	{
! 	    cc = gchar_cursor();
  	    if (WHITECHAR(cc))
  	    {
  		/* remember position of blank just before text */
! 		end_foundcol = curwin->w_cursor.col;
  
  		/* find start of sequence of blanks */
  		while (curwin->w_cursor.col > 0 && WHITECHAR(cc))
--- 5849,5862 ----
  		    || curwin->w_cursor.lnum != Insstart.lnum
  		    || curwin->w_cursor.col >= Insstart.col)
  	{
! 	    if (curwin->w_cursor.col == startcol && c != NUL)
! 		cc = c;
! 	    else
! 		cc = gchar_cursor();
  	    if (WHITECHAR(cc))
  	    {
  		/* remember position of blank just before text */
! 		end_col = curwin->w_cursor.col;
  
  		/* find start of sequence of blanks */
  		while (curwin->w_cursor.col > 0 && WHITECHAR(cc))
***************
*** 5871,5877 ****
  		    /* do not break after one-letter words */
  		    if (curwin->w_cursor.col == 0)
  			break;	/* one-letter word at begin */
! 
  		    col = curwin->w_cursor.col;
  		    dec_cursor();
  		    cc = gchar_cursor();
--- 5876,5886 ----
  		    /* do not break after one-letter words */
  		    if (curwin->w_cursor.col == 0)
  			break;	/* one-letter word at begin */
! #ifdef FEAT_COMMENTS
! 		    /* do not break "#a b" when 'tw' is 2 */
! 		    if (curwin->w_cursor.col <= leader_len)
! 			break;
! #endif
  		    col = curwin->w_cursor.col;
  		    dec_cursor();
  		    cc = gchar_cursor();
***************
*** 5880,5905 ****
  			continue;	/* one-letter, continue */
  		    curwin->w_cursor.col = col;
  		}
! #ifdef FEAT_MBYTE
! 		if (has_mbyte)
! 		    foundcol = curwin->w_cursor.col
! 					 + (*mb_ptr2len)(ml_get_cursor());
! 		else
! #endif
! 		    foundcol = curwin->w_cursor.col + 1;
! 		if (curwin->w_cursor.col < (colnr_T)wantcol)
  		    break;
  	    }
  #ifdef FEAT_MBYTE
! 	    else if (cc >= 0x100 && fo_multibyte
! 			      && curwin->w_cursor.col <= (colnr_T)wantcol)
  	    {
  		/* Break after or before a multi-byte character. */
  		foundcol = curwin->w_cursor.col;
- 		if (curwin->w_cursor.col < (colnr_T)wantcol)
- 		    foundcol += (*mb_char2len)(cc);
  		end_foundcol = foundcol;
! 		break;
  	    }
  #endif
  	    if (curwin->w_cursor.col == 0)
--- 5889,5948 ----
  			continue;	/* one-letter, continue */
  		    curwin->w_cursor.col = col;
  		}
! 
! 		inc_cursor();
! 
! 		end_foundcol = end_col + 1;
! 		foundcol = curwin->w_cursor.col;
! 		if (curwin->w_cursor.col <= (colnr_T)wantcol)
  		    break;
  	    }
  #ifdef FEAT_MBYTE
! 	    else if (cc >= 0x100 && fo_multibyte)
  	    {
  		/* Break after or before a multi-byte character. */
+ 		if (curwin->w_cursor.col != startcol)
+ 		{
+ #ifdef FEAT_COMMENTS
+ 		    /* Don't break until after the comment leader */
+ 		    if (curwin->w_cursor.col < leader_len)
+ 			break;
+ #endif
+ 		    col = curwin->w_cursor.col;
+ 		    inc_cursor();
+ 		    /* Don't change end_foundcol if already set. */
+ 		    if (foundcol != curwin->w_cursor.col)
+ 		    {
+ 			foundcol = curwin->w_cursor.col;
+ 			end_foundcol = foundcol;
+ 			if (curwin->w_cursor.col <= (colnr_T)wantcol)
+ 			    break;
+ 		    }
+ 		    curwin->w_cursor.col = col;
+ 		}
+ 
+ 		if (curwin->w_cursor.col == 0)
+ 		    break;
+ 
+ 		col = curwin->w_cursor.col;
+ 
+ 		dec_cursor();
+ 		cc = gchar_cursor();
+ 
+ 		if (WHITECHAR(cc))
+ 		    continue;		/* break with space */
+ #ifdef FEAT_COMMENTS
+ 		/* Don't break until after the comment leader */
+ 		if (curwin->w_cursor.col < leader_len)
+ 		    break;
+ #endif
+ 
+ 		curwin->w_cursor.col = col;
+ 
  		foundcol = curwin->w_cursor.col;
  		end_foundcol = foundcol;
! 		if (curwin->w_cursor.col <= (colnr_T)wantcol)
! 		    break;
  	    }
  #endif
  	    if (curwin->w_cursor.col == 0)
***************
*** 5926,5939 ****
  	    orig_col = startcol;	/* Will start backspacing from here */
  	else
  #endif
! 	    replace_offset = startcol - end_foundcol - 1;
  
  	/*
  	 * adjust startcol for spaces that will be deleted and
  	 * characters that will remain on top line
  	 */
  	curwin->w_cursor.col = foundcol;
! 	while (cc = gchar_cursor(), WHITECHAR(cc))
  	    inc_cursor();
  	startcol -= curwin->w_cursor.col;
  	if (startcol < 0)
--- 5969,5983 ----
  	    orig_col = startcol;	/* Will start backspacing from here */
  	else
  #endif
! 	    replace_offset = startcol - end_foundcol;
  
  	/*
  	 * adjust startcol for spaces that will be deleted and
  	 * characters that will remain on top line
  	 */
  	curwin->w_cursor.col = foundcol;
! 	while ((cc = gchar_cursor(), WHITECHAR(cc))
! 		    && (!fo_white_par || curwin->w_cursor.col < startcol))
  	    inc_cursor();
  	startcol -= curwin->w_cursor.col;
  	if (startcol < 0)
***************
*** 8509,8515 ****
  	if (mode == BACKSPACE_LINE
  		&& (curbuf->b_p_ai
  #ifdef FEAT_CINDENT
!                     || cindent_on()
  #endif
  		   )
  #ifdef FEAT_RIGHTLEFT
--- 8553,8559 ----
  	if (mode == BACKSPACE_LINE
  		&& (curbuf->b_p_ai
  #ifdef FEAT_CINDENT
! 		    || cindent_on()
  #endif
  		   )
  #ifdef FEAT_RIGHTLEFT
*** ../vim-7.2.300/src/testdir/Makefile	2009-11-17 17:36:13.000000000 +0100
--- src/testdir/Makefile	2009-11-17 15:11:26.000000000 +0100
***************
*** 22,28 ****
  		test48.out test49.out test51.out test52.out test53.out \
  		test54.out test55.out test56.out test57.out test58.out \
  		test59.out test60.out test61.out test62.out test63.out \
! 		test64.out test65.out test66.out test67.out
  
  SCRIPTS_GUI = test16.out
  
--- 22,29 ----
  		test48.out test49.out test51.out test52.out test53.out \
  		test54.out test55.out 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
  
  SCRIPTS_GUI = test16.out
  
*** ../vim-7.2.300/src/testdir/test68.in	2009-11-17 17:39:36.000000000 +0100
--- src/testdir/test68.in	2009-11-17 15:39:09.000000000 +0100
***************
*** 0 ****
--- 1,56 ----
+ Test for text formatting.
+ 
+ Results of test68:
+ 
+ STARTTEST
+ :so small.vim
+ /^{/+1
+ :set noai tw=2 fo=t
+ gRa b
+ ENDTEST
+ 
+ {
+     
+ 
+ }
+ 
+ STARTTEST
+ /^{/+1
+ :set ai tw=2 fo=tw
+ gqgqjjllab
+ ENDTEST
+ 
+ {
+ a  b  
+ 
+ a    
+ }
+ 
+ STARTTEST
+ /^{/+1
+ :set tw=3 fo=t
+ gqgqo
+ a 
+ ENDTEST
+ 
+ {
+ a 
+ }
+ 
+ STARTTEST
+ /^{/+1
+ :set tw=2 fo=tcq1 comments=:#
+ gqgqjgqgqo
+ a b
+ #a b
+ ENDTEST
+ 
+ {
+ a b
+ #a b
+ }
+ 
+ STARTTEST
+ :g/^STARTTEST/.,/^ENDTEST/d
+ :1;/^Results/,$wq! test.out
+ ENDTEST
*** ../vim-7.2.300/src/testdir/test68.ok	2009-11-17 17:39:36.000000000 +0100
--- src/testdir/test68.ok	2009-11-17 15:11:26.000000000 +0100
***************
*** 0 ****
--- 1,35 ----
+ Results of test68:
+ 
+ 
+ {
+ a
+ b
+ }
+ 
+ 
+ {
+ a  
+ b  
+ 
+ a  
+ b
+ }
+ 
+ 
+ {
+ a
+ 
+ 
+ a
+ 
+ }
+ 
+ 
+ {
+ a b
+ #a b
+ 
+ a b
+ #a b
+ }
+ 
*** ../vim-7.2.300/src/testdir/test69.in	2009-11-17 17:39:36.000000000 +0100
--- src/testdir/test69.in	2009-11-17 15:11:26.000000000 +0100
***************
*** 0 ****
--- 1,139 ----
+ Test for multi-byte text formatting.
+ 
+ STARTTEST
+ :so mbyte.vim
+ :set encoding=utf-8
+ ENDTEST
+ 
+ Results of test69:
+ 
+ STARTTEST
+ /^{/+1
+ :set tw=2 fo=t
+ gqgqjgqgqo
+ XYZ
+ abc XYZ
+ ENDTEST
+ 
+ {
+ XYZ
+ abc XYZ
+ }
+ 
+ STARTTEST
+ /^{/+1
+ :set tw=1 fo=tm
+ gqgqjgqgqjgqgqjgqgqjgqgqo
+ X
+ Xa
+ X a
+ XY
+ X Y
+ ENDTEST
+ 
+ {
+ X
+ Xa
+ X a
+ XY
+ X Y
+ }
+ 
+ STARTTEST
+ /^{/+1
+ :set tw=2 fo=tm
+ gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo
+ X
+ Xa
+ X a
+ XY
+ X Y
+ aX
+ abX
+ abcX
+ abX c
+ abXY
+ ENDTEST
+ 
+ {
+ X
+ Xa
+ X a
+ XY
+ X Y
+ aX
+ abX
+ abcX
+ abX c
+ abXY
+ }
+ 
+ STARTTEST
+ /^{/+1
+ :set ai tw=2 fo=tm
+ gqgqjgqgqo
+ X
+ Xa
+ ENDTEST
+ 
+ {
+   X
+   Xa
+ }
+ 
+ STARTTEST
+ /^{/+1
+ :set noai tw=2 fo=tm
+ gqgqjgqgqo
+   X
+   Xa
+ ENDTEST
+ 
+ {
+   X
+   Xa
+ }
+ 
+ STARTTEST
+ /^{/+1
+ :set tw=2 fo=cqm comments=n:X
+ gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo
+ X
+ Xa
+ XaY
+ XY
+ XYZ
+ X Y
+ X YZ
+ XX
+ XXa
+ XXY
+ ENDTEST
+ 
+ {
+ X
+ Xa
+ XaY
+ XY
+ XYZ
+ X Y
+ X YZ
+ XX
+ XXa
+ XXY
+ }
+ 
+ STARTTEST
+ /^{/+1
+ :set tw=2 fo=tm
+ RXa
+ ENDTEST
+ 
+ {
+ 
+ }
+ 
+ STARTTEST
+ :g/^STARTTEST/.,/^ENDTEST/d
+ :1;/^Results/,$wq! test.out
+ ENDTEST
*** ../vim-7.2.300/src/testdir/test69.ok	2009-11-17 17:39:36.000000000 +0100
--- src/testdir/test69.ok	2009-11-17 15:11:26.000000000 +0100
***************
*** 0 ****
--- 1,142 ----
+ Results of test69:
+ 
+ 
+ {
+ XYZ
+ abc
+ XYZ
+ 
+ XYZ
+ abc
+ XYZ
+ }
+ 
+ 
+ {
+ X
+ X
+ a
+ X
+ a
+ X
+ Y
+ X
+ Y
+ 
+ X
+ X
+ a
+ X
+ a
+ X
+ Y
+ X
+ Y
+ }
+ 
+ 
+ {
+ X
+ X
+ a
+ X
+ a
+ X
+ Y
+ X
+ Y
+ a
+ X
+ ab
+ X
+ abc
+ X
+ ab
+ X
+ c
+ ab
+ X
+ Y
+ 
+ X
+ X
+ a
+ X
+ a
+ X
+ Y
+ X
+ Y
+ a
+ X
+ ab
+ X
+ abc
+ X
+ ab
+ X
+ c
+ ab
+ X
+ Y
+ }
+ 
+ 
+ {
+   X
+   X
+   a
+ 
+   X
+   X
+   a
+ }
+ 
+ 
+ {
+   X
+   X
+ a
+ 
+   X
+   X
+ a
+ }
+ 
+ 
+ {
+ X
+ Xa
+ Xa
+ XY
+ XY
+ XY
+ XZ
+ X Y
+ X Y
+ X Z
+ XX
+ XXa
+ XXY
+ 
+ X
+ Xa
+ Xa
+ XY
+ XY
+ XY
+ XZ
+ X Y
+ X Y
+ X Z
+ XX
+ XXa
+ XXY
+ }
+ 
+ 
+ {
+ X
+ a
+ }
+ 
*** ../vim-7.2.300/src/version.c	2009-11-17 17:37:34.000000000 +0100
--- src/version.c	2009-11-17 17:26:35.000000000 +0100
***************
*** 683,684 ****
--- 683,686 ----
  {   /* Add new patch number below this line */
+ /**/
+     301,
  /**/