]> git.pld-linux.org Git - packages/vim.git/blob - 7.2.301
- new
[packages/vim.git] / 7.2.301
1 To: vim-dev@vim.org
2 Subject: Patch 7.2.301
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 NOTE: some mail and patch programs may have a problem with the non-ASCII
11 characters in this patch.  You can fetch the patch from
12 ftp://ftp.vim.org/pub/vim/patches/7.2/7.2.301  and/or fetch the updated
13 files from CVS.  http://www.vim.org/cvs.php
14
15
16 Patch 7.2.301
17 Problem:    Formatting is wrong when 'tw' is set to a small value.
18 Solution:   Fix it and add tests.  Also fix behavior of "1" in 'fo'. (Yukihiro
19             Nakadaira)
20 Files:      src/edit.c, src/testdir/Makefile, src/testdir/test68.in,
21             src/testdir/test68.ok, src/testdir/test69.in,
22             src/testdir/test69.ok
23
24
25 *** ../vim-7.2.300/src/edit.c   2009-11-11 13:22:32.000000000 +0100
26 --- src/edit.c  2009-11-17 15:34:47.000000000 +0100
27 ***************
28 *** 181,187 ****
29   static void ins_ctrl_v __ARGS((void));
30   static void undisplay_dollar __ARGS((void));
31   static void insert_special __ARGS((int, int, int));
32 ! static void internal_format __ARGS((int textwidth, int second_indent, int flags, int format_only));
33   static void check_auto_format __ARGS((int));
34   static void redo_literal __ARGS((int c));
35   static void start_arrow __ARGS((pos_T *end_insert_pos));
36 --- 181,187 ----
37   static void ins_ctrl_v __ARGS((void));
38   static void undisplay_dollar __ARGS((void));
39   static void insert_special __ARGS((int, int, int));
40 ! static void internal_format __ARGS((int textwidth, int second_indent, int flags, int format_only, int c));
41   static void check_auto_format __ARGS((int));
42   static void redo_literal __ARGS((int c));
43   static void start_arrow __ARGS((pos_T *end_insert_pos));
44 ***************
45 *** 2164,2170 ****
46       int               i, c;
47       int               actual_len;             /* Take multi-byte characters */
48       int               actual_compl_length;    /* into account. */
49 !     int               *wca;                   /* Wide character array. */
50       int               has_lower = FALSE;
51       int               was_letter = FALSE;
52   
53 --- 2164,2170 ----
54       int               i, c;
55       int               actual_len;             /* Take multi-byte characters */
56       int               actual_compl_length;    /* into account. */
57 !     int               *wca;                   /* Wide character array. */
58       int               has_lower = FALSE;
59       int               was_letter = FALSE;
60   
61 ***************
62 *** 5558,5564 ****
63         }
64         if (do_internal)
65   #endif
66 !           internal_format(textwidth, second_indent, flags, c == NUL);
67       }
68   
69       if (c == NUL)         /* only formatting was wanted */
70 --- 5558,5564 ----
71         }
72         if (do_internal)
73   #endif
74 !           internal_format(textwidth, second_indent, flags, c == NUL, c);
75       }
76   
77       if (c == NUL)         /* only formatting was wanted */
78 ***************
79 *** 5738,5748 ****
80    * Format text at the current insert position.
81    */
82       static void
83 ! internal_format(textwidth, second_indent, flags, format_only)
84       int               textwidth;
85       int               second_indent;
86       int               flags;
87       int               format_only;
88   {
89       int               cc;
90       int               save_char = NUL;
91 --- 5738,5749 ----
92    * Format text at the current insert position.
93    */
94       static void
95 ! internal_format(textwidth, second_indent, flags, format_only, c)
96       int               textwidth;
97       int               second_indent;
98       int               flags;
99       int               format_only;
100 +     int               c; /* character to be inserted (can be NUL) */
101   {
102       int               cc;
103       int               save_char = NUL;
104 ***************
105 *** 5763,5769 ****
106        * When 'ai' is off we don't want a space under the cursor to be
107        * deleted.  Replace it with an 'x' temporarily.
108        */
109 !     if (!curbuf->b_p_ai)
110       {
111         cc = gchar_cursor();
112         if (vim_iswhite(cc))
113 --- 5764,5774 ----
114        * When 'ai' is off we don't want a space under the cursor to be
115        * deleted.  Replace it with an 'x' temporarily.
116        */
117 !     if (!curbuf->b_p_ai
118 ! #ifdef FEAT_VREPLACE
119 !           && !(State & VREPLACE_FLAG)
120 ! #endif
121 !           )
122       {
123         cc = gchar_cursor();
124         if (vim_iswhite(cc))
125 ***************
126 *** 5789,5797 ****
127         char_u  *saved_text = NULL;
128   #endif
129         colnr_T col;
130   
131 !       virtcol = get_nolist_virtcol();
132 !       if (virtcol < (colnr_T)textwidth)
133             break;
134   
135   #ifdef FEAT_COMMENTS
136 --- 5794,5804 ----
137         char_u  *saved_text = NULL;
138   #endif
139         colnr_T col;
140 +       colnr_T end_col;
141   
142 !       virtcol = get_nolist_virtcol()
143 !               + char2cells(c != NUL ? c : gchar_cursor());
144 !       if (virtcol <= (colnr_T)textwidth)
145             break;
146   
147   #ifdef FEAT_COMMENTS
148 ***************
149 *** 5831,5842 ****
150         coladvance((colnr_T)textwidth);
151         wantcol = curwin->w_cursor.col;
152   
153 !       curwin->w_cursor.col = startcol - 1;
154 ! #ifdef FEAT_MBYTE
155 !       /* Correct cursor for multi-byte character. */
156 !       if (has_mbyte)
157 !           mb_adjust_cursor();
158 ! #endif
159         foundcol = 0;
160   
161         /*
162 --- 5838,5844 ----
163         coladvance((colnr_T)textwidth);
164         wantcol = curwin->w_cursor.col;
165   
166 !       curwin->w_cursor.col = startcol;
167         foundcol = 0;
168   
169         /*
170 ***************
171 *** 5847,5857 ****
172                     || curwin->w_cursor.lnum != Insstart.lnum
173                     || curwin->w_cursor.col >= Insstart.col)
174         {
175 !           cc = gchar_cursor();
176             if (WHITECHAR(cc))
177             {
178                 /* remember position of blank just before text */
179 !               end_foundcol = curwin->w_cursor.col;
180   
181                 /* find start of sequence of blanks */
182                 while (curwin->w_cursor.col > 0 && WHITECHAR(cc))
183 --- 5849,5862 ----
184                     || curwin->w_cursor.lnum != Insstart.lnum
185                     || curwin->w_cursor.col >= Insstart.col)
186         {
187 !           if (curwin->w_cursor.col == startcol && c != NUL)
188 !               cc = c;
189 !           else
190 !               cc = gchar_cursor();
191             if (WHITECHAR(cc))
192             {
193                 /* remember position of blank just before text */
194 !               end_col = curwin->w_cursor.col;
195   
196                 /* find start of sequence of blanks */
197                 while (curwin->w_cursor.col > 0 && WHITECHAR(cc))
198 ***************
199 *** 5871,5877 ****
200                     /* do not break after one-letter words */
201                     if (curwin->w_cursor.col == 0)
202                         break;  /* one-letter word at begin */
203
204                     col = curwin->w_cursor.col;
205                     dec_cursor();
206                     cc = gchar_cursor();
207 --- 5876,5886 ----
208                     /* do not break after one-letter words */
209                     if (curwin->w_cursor.col == 0)
210                         break;  /* one-letter word at begin */
211 ! #ifdef FEAT_COMMENTS
212 !                   /* do not break "#a b" when 'tw' is 2 */
213 !                   if (curwin->w_cursor.col <= leader_len)
214 !                       break;
215 ! #endif
216                     col = curwin->w_cursor.col;
217                     dec_cursor();
218                     cc = gchar_cursor();
219 ***************
220 *** 5880,5905 ****
221                         continue;       /* one-letter, continue */
222                     curwin->w_cursor.col = col;
223                 }
224 ! #ifdef FEAT_MBYTE
225 !               if (has_mbyte)
226 !                   foundcol = curwin->w_cursor.col
227 !                                        + (*mb_ptr2len)(ml_get_cursor());
228 !               else
229 ! #endif
230 !                   foundcol = curwin->w_cursor.col + 1;
231 !               if (curwin->w_cursor.col < (colnr_T)wantcol)
232                     break;
233             }
234   #ifdef FEAT_MBYTE
235 !           else if (cc >= 0x100 && fo_multibyte
236 !                             && curwin->w_cursor.col <= (colnr_T)wantcol)
237             {
238                 /* Break after or before a multi-byte character. */
239                 foundcol = curwin->w_cursor.col;
240 -               if (curwin->w_cursor.col < (colnr_T)wantcol)
241 -                   foundcol += (*mb_char2len)(cc);
242                 end_foundcol = foundcol;
243 !               break;
244             }
245   #endif
246             if (curwin->w_cursor.col == 0)
247 --- 5889,5948 ----
248                         continue;       /* one-letter, continue */
249                     curwin->w_cursor.col = col;
250                 }
251
252 !               inc_cursor();
253
254 !               end_foundcol = end_col + 1;
255 !               foundcol = curwin->w_cursor.col;
256 !               if (curwin->w_cursor.col <= (colnr_T)wantcol)
257                     break;
258             }
259   #ifdef FEAT_MBYTE
260 !           else if (cc >= 0x100 && fo_multibyte)
261             {
262                 /* Break after or before a multi-byte character. */
263 +               if (curwin->w_cursor.col != startcol)
264 +               {
265 + #ifdef FEAT_COMMENTS
266 +                   /* Don't break until after the comment leader */
267 +                   if (curwin->w_cursor.col < leader_len)
268 +                       break;
269 + #endif
270 +                   col = curwin->w_cursor.col;
271 +                   inc_cursor();
272 +                   /* Don't change end_foundcol if already set. */
273 +                   if (foundcol != curwin->w_cursor.col)
274 +                   {
275 +                       foundcol = curwin->w_cursor.col;
276 +                       end_foundcol = foundcol;
277 +                       if (curwin->w_cursor.col <= (colnr_T)wantcol)
278 +                           break;
279 +                   }
280 +                   curwin->w_cursor.col = col;
281 +               }
282
283 +               if (curwin->w_cursor.col == 0)
284 +                   break;
285
286 +               col = curwin->w_cursor.col;
287
288 +               dec_cursor();
289 +               cc = gchar_cursor();
290
291 +               if (WHITECHAR(cc))
292 +                   continue;           /* break with space */
293 + #ifdef FEAT_COMMENTS
294 +               /* Don't break until after the comment leader */
295 +               if (curwin->w_cursor.col < leader_len)
296 +                   break;
297 + #endif
298
299 +               curwin->w_cursor.col = col;
300
301                 foundcol = curwin->w_cursor.col;
302                 end_foundcol = foundcol;
303 !               if (curwin->w_cursor.col <= (colnr_T)wantcol)
304 !                   break;
305             }
306   #endif
307             if (curwin->w_cursor.col == 0)
308 ***************
309 *** 5926,5939 ****
310             orig_col = startcol;        /* Will start backspacing from here */
311         else
312   #endif
313 !           replace_offset = startcol - end_foundcol - 1;
314   
315         /*
316          * adjust startcol for spaces that will be deleted and
317          * characters that will remain on top line
318          */
319         curwin->w_cursor.col = foundcol;
320 !       while (cc = gchar_cursor(), WHITECHAR(cc))
321             inc_cursor();
322         startcol -= curwin->w_cursor.col;
323         if (startcol < 0)
324 --- 5969,5983 ----
325             orig_col = startcol;        /* Will start backspacing from here */
326         else
327   #endif
328 !           replace_offset = startcol - end_foundcol;
329   
330         /*
331          * adjust startcol for spaces that will be deleted and
332          * characters that will remain on top line
333          */
334         curwin->w_cursor.col = foundcol;
335 !       while ((cc = gchar_cursor(), WHITECHAR(cc))
336 !                   && (!fo_white_par || curwin->w_cursor.col < startcol))
337             inc_cursor();
338         startcol -= curwin->w_cursor.col;
339         if (startcol < 0)
340 ***************
341 *** 8509,8515 ****
342         if (mode == BACKSPACE_LINE
343                 && (curbuf->b_p_ai
344   #ifdef FEAT_CINDENT
345 !                     || cindent_on()
346   #endif
347                    )
348   #ifdef FEAT_RIGHTLEFT
349 --- 8553,8559 ----
350         if (mode == BACKSPACE_LINE
351                 && (curbuf->b_p_ai
352   #ifdef FEAT_CINDENT
353 !                   || cindent_on()
354   #endif
355                    )
356   #ifdef FEAT_RIGHTLEFT
357 *** ../vim-7.2.300/src/testdir/Makefile 2009-11-17 17:36:13.000000000 +0100
358 --- src/testdir/Makefile        2009-11-17 15:11:26.000000000 +0100
359 ***************
360 *** 22,28 ****
361                 test48.out test49.out test51.out test52.out test53.out \
362                 test54.out test55.out test56.out test57.out test58.out \
363                 test59.out test60.out test61.out test62.out test63.out \
364 !               test64.out test65.out test66.out test67.out
365   
366   SCRIPTS_GUI = test16.out
367   
368 --- 22,29 ----
369                 test48.out test49.out test51.out test52.out test53.out \
370                 test54.out test55.out test56.out test57.out test58.out \
371                 test59.out test60.out test61.out test62.out test63.out \
372 !               test64.out test65.out test66.out test67.out test68.out \
373 !               test69.out
374   
375   SCRIPTS_GUI = test16.out
376   
377 *** ../vim-7.2.300/src/testdir/test68.in        2009-11-17 17:39:36.000000000 +0100
378 --- src/testdir/test68.in       2009-11-17 15:39:09.000000000 +0100
379 ***************
380 *** 0 ****
381 --- 1,56 ----
382 + Test for text formatting.
383
384 + Results of test68:
385
386 + STARTTEST
387 + :so small.vim
388 + /^{/+1
389 + :set noai tw=2 fo=t
390 + gRa b\e
391 + ENDTEST
392
393 + {
394 +     
395
396 + }
397
398 + STARTTEST
399 + /^{/+1
400 + :set ai tw=2 fo=tw
401 + gqgqjjllab\e
402 + ENDTEST
403
404 + {
405 + a  b  
406
407 + a    
408 + }
409
410 + STARTTEST
411 + /^{/+1
412 + :set tw=3 fo=t
413 + gqgqo
414 + a \16\ 1\e
415 + ENDTEST
416
417 + {
418 + a \ 1
419 + }
420
421 + STARTTEST
422 + /^{/+1
423 + :set tw=2 fo=tcq1 comments=:#
424 + gqgqjgqgqo
425 + a b
426 + #a b\e
427 + ENDTEST
428
429 + {
430 + a b
431 + #a b
432 + }
433
434 + STARTTEST
435 + :g/^STARTTEST/.,/^ENDTEST/d
436 + :1;/^Results/,$wq! test.out
437 + ENDTEST
438 *** ../vim-7.2.300/src/testdir/test68.ok        2009-11-17 17:39:36.000000000 +0100
439 --- src/testdir/test68.ok       2009-11-17 15:11:26.000000000 +0100
440 ***************
441 *** 0 ****
442 --- 1,35 ----
443 + Results of test68:
444
445
446 + {
447 + a
448 + b
449 + }
450
451
452 + {
453 + a  
454 + b  
455
456 + a  
457 + b
458 + }
459
460
461 + {
462 + a
463\ 1
464
465 + a
466\ 1
467 + }
468
469
470 + {
471 + a b
472 + #a b
473
474 + a b
475 + #a b
476 + }
477
478 *** ../vim-7.2.300/src/testdir/test69.in        2009-11-17 17:39:36.000000000 +0100
479 --- src/testdir/test69.in       2009-11-17 15:11:26.000000000 +0100
480 ***************
481 *** 0 ****
482 --- 1,139 ----
483 + Test for multi-byte text formatting.
484
485 + STARTTEST
486 + :so mbyte.vim
487 + :set encoding=utf-8
488 + ENDTEST
489
490 + Results of test69:
491
492 + STARTTEST
493 + /^{/+1
494 + :set tw=2 fo=t
495 + gqgqjgqgqo
496 + XYZ
497 + abc XYZ\e
498 + ENDTEST
499
500 + {
501 + XYZ
502 + abc XYZ
503 + }
504
505 + STARTTEST
506 + /^{/+1
507 + :set tw=1 fo=tm
508 + gqgqjgqgqjgqgqjgqgqjgqgqo
509 + X
510 + Xa
511 + X a
512 + XY
513 + X Y\e
514 + ENDTEST
515
516 + {
517 + X
518 + Xa
519 + X a
520 + XY
521 + X Y
522 + }
523
524 + STARTTEST
525 + /^{/+1
526 + :set tw=2 fo=tm
527 + gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo
528 + X
529 + Xa
530 + X a
531 + XY
532 + X Y
533 + aX
534 + abX
535 + abcX
536 + abX c
537 + abXY\e
538 + ENDTEST
539
540 + {
541 + X
542 + Xa
543 + X a
544 + XY
545 + X Y
546 + aX
547 + abX
548 + abcX
549 + abX c
550 + abXY
551 + }
552
553 + STARTTEST
554 + /^{/+1
555 + :set ai tw=2 fo=tm
556 + gqgqjgqgqo
557 + X
558 + Xa\e
559 + ENDTEST
560
561 + {
562 +   X
563 +   Xa
564 + }
565
566 + STARTTEST
567 + /^{/+1
568 + :set noai tw=2 fo=tm
569 + gqgqjgqgqo
570 +   X
571 +   Xa\e
572 + ENDTEST
573
574 + {
575 +   X
576 +   Xa
577 + }
578
579 + STARTTEST
580 + /^{/+1
581 + :set tw=2 fo=cqm comments=n:X
582 + gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo
583 + X
584 + Xa
585 + XaY
586 + XY
587 + XYZ
588 + X Y
589 + X YZ
590 + XX
591 + XXa
592 + XXY\e
593 + ENDTEST
594
595 + {
596 + X
597 + Xa
598 + XaY
599 + XY
600 + XYZ
601 + X Y
602 + X YZ
603 + XX
604 + XXa
605 + XXY
606 + }
607
608 + STARTTEST
609 + /^{/+1
610 + :set tw=2 fo=tm
611 + RXa\e
612 + ENDTEST
613
614 + {
615
616 + }
617
618 + STARTTEST
619 + :g/^STARTTEST/.,/^ENDTEST/d
620 + :1;/^Results/,$wq! test.out
621 + ENDTEST
622 *** ../vim-7.2.300/src/testdir/test69.ok        2009-11-17 17:39:36.000000000 +0100
623 --- src/testdir/test69.ok       2009-11-17 15:11:26.000000000 +0100
624 ***************
625 *** 0 ****
626 --- 1,142 ----
627 + Results of test69:
628
629
630 + {
631 + XYZ
632 + abc
633 + XYZ
634
635 + XYZ
636 + abc
637 + XYZ
638 + }
639
640
641 + {
642 + X
643 + X
644 + a
645 + X
646 + a
647 + X
648 + Y
649 + X
650 + Y
651
652 + X
653 + X
654 + a
655 + X
656 + a
657 + X
658 + Y
659 + X
660 + Y
661 + }
662
663
664 + {
665 + X
666 + X
667 + a
668 + X
669 + a
670 + X
671 + Y
672 + X
673 + Y
674 + a
675 + X
676 + ab
677 + X
678 + abc
679 + X
680 + ab
681 + X
682 + c
683 + ab
684 + X
685 + Y
686
687 + X
688 + X
689 + a
690 + X
691 + a
692 + X
693 + Y
694 + X
695 + Y
696 + a
697 + X
698 + ab
699 + X
700 + abc
701 + X
702 + ab
703 + X
704 + c
705 + ab
706 + X
707 + Y
708 + }
709
710
711 + {
712 +   X
713 +   X
714 +   a
715
716 +   X
717 +   X
718 +   a
719 + }
720
721
722 + {
723 +   X
724 +   X
725 + a
726
727 +   X
728 +   X
729 + a
730 + }
731
732
733 + {
734 + X
735 + Xa
736 + Xa
737 + XY
738 + XY
739 + XY
740 + XZ
741 + X Y
742 + X Y
743 + X Z
744 + XX
745 + XXa
746 + XXY
747
748 + X
749 + Xa
750 + Xa
751 + XY
752 + XY
753 + XY
754 + XZ
755 + X Y
756 + X Y
757 + X Z
758 + XX
759 + XXa
760 + XXY
761 + }
762
763
764 + {
765 + X
766 + a
767 + }
768
769 *** ../vim-7.2.300/src/version.c        2009-11-17 17:37:34.000000000 +0100
770 --- src/version.c       2009-11-17 17:26:35.000000000 +0100
771 ***************
772 *** 683,684 ****
773 --- 683,686 ----
774   {   /* Add new patch number below this line */
775 + /**/
776 +     301,
777   /**/
This page took 1.368199 seconds and 3 git commands to generate.