]> granicus.if.org Git - vim/commitdiff
updated for version 7.2-301 v7.2.301
authorBram Moolenaar <Bram@vim.org>
Tue, 17 Nov 2009 16:41:01 +0000 (16:41 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 17 Nov 2009 16:41:01 +0000 (16:41 +0000)
src/edit.c
src/testdir/Makefile
src/testdir/test68.in [new file with mode: 0644]
src/testdir/test68.ok [new file with mode: 0644]
src/testdir/test69.in [new file with mode: 0644]
src/testdir/test69.ok [new file with mode: 0644]
src/version.c

index d825d83eaf792bf8a9803ee430f01ba2f2a9fc17..19e5b8d5ec0e5069070b4db70a7e8de3e07ee504 100644 (file)
@@ -181,7 +181,7 @@ static void ins_redraw __ARGS((int ready));
 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 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,7 +2164,7 @@ ins_compl_add_infercase(str, len, icase, fname, dir, flags)
     int                i, c;
     int                actual_len;             /* Take multi-byte characters */
     int                actual_compl_length;    /* into account. */
-    int                *wca;                   /* Wide character array. */
+    int                *wca;                   /* Wide character array. */
     int                has_lower = FALSE;
     int                was_letter = FALSE;
 
@@ -5558,7 +5558,7 @@ insertchar(c, flags, second_indent)
        }
        if (do_internal)
 #endif
-           internal_format(textwidth, second_indent, flags, c == NUL);
+           internal_format(textwidth, second_indent, flags, c == NUL, c);
     }
 
     if (c == NUL)          /* only formatting was wanted */
@@ -5738,11 +5738,12 @@ insertchar(c, flags, second_indent)
  * Format text at the current insert position.
  */
     static void
-internal_format(textwidth, second_indent, flags, format_only)
+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,7 +5764,11 @@ internal_format(textwidth, second_indent, flags, format_only)
      * 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)
+    if (!curbuf->b_p_ai
+#ifdef FEAT_VREPLACE
+           && !(State & VREPLACE_FLAG)
+#endif
+           )
     {
        cc = gchar_cursor();
        if (vim_iswhite(cc))
@@ -5789,9 +5794,11 @@ internal_format(textwidth, second_indent, flags, format_only)
        char_u  *saved_text = NULL;
 #endif
        colnr_T col;
+       colnr_T end_col;
 
-       virtcol = get_nolist_virtcol();
-       if (virtcol < (colnr_T)textwidth)
+       virtcol = get_nolist_virtcol()
+               + char2cells(c != NUL ? c : gchar_cursor());
+       if (virtcol <= (colnr_T)textwidth)
            break;
 
 #ifdef FEAT_COMMENTS
@@ -5831,12 +5838,7 @@ internal_format(textwidth, second_indent, flags, format_only)
        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
+       curwin->w_cursor.col = startcol;
        foundcol = 0;
 
        /*
@@ -5847,11 +5849,14 @@ internal_format(textwidth, second_indent, flags, format_only)
                    || curwin->w_cursor.lnum != Insstart.lnum
                    || curwin->w_cursor.col >= Insstart.col)
        {
-           cc = gchar_cursor();
+           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_foundcol = curwin->w_cursor.col;
+               end_col = curwin->w_cursor.col;
 
                /* find start of sequence of blanks */
                while (curwin->w_cursor.col > 0 && WHITECHAR(cc))
@@ -5871,7 +5876,11 @@ internal_format(textwidth, second_indent, flags, format_only)
                    /* 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,26 +5889,60 @@ internal_format(textwidth, second_indent, flags, format_only)
                        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)
+
+               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
-                             && curwin->w_cursor.col <= (colnr_T)wantcol)
+           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;
-               if (curwin->w_cursor.col < (colnr_T)wantcol)
-                   foundcol += (*mb_char2len)(cc);
                end_foundcol = foundcol;
-               break;
+               if (curwin->w_cursor.col <= (colnr_T)wantcol)
+                   break;
            }
 #endif
            if (curwin->w_cursor.col == 0)
@@ -5926,14 +5969,15 @@ internal_format(textwidth, second_indent, flags, format_only)
            orig_col = startcol;        /* Will start backspacing from here */
        else
 #endif
-           replace_offset = startcol - end_foundcol - 1;
+           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))
+       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,7 +8553,7 @@ ins_bs(c, mode, inserted_space_p)
        if (mode == BACKSPACE_LINE
                && (curbuf->b_p_ai
 #ifdef FEAT_CINDENT
-                    || cindent_on()
+                   || cindent_on()
 #endif
                   )
 #ifdef FEAT_RIGHTLEFT
index 8f9fd1356107af3aa07cc161d218e46acc4aebaf..efad475bf6bd36ba013c68dab8f762ba6b7e6a22 100644 (file)
@@ -22,7 +22,8 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
                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
+               test64.out test65.out test66.out test67.out test68.out \
+               test69.out
 
 SCRIPTS_GUI = test16.out
 
diff --git a/src/testdir/test68.in b/src/testdir/test68.in
new file mode 100644 (file)
index 0000000..94104c0
--- /dev/null
@@ -0,0 +1,56 @@
+Test for text formatting.
+
+Results of test68:
+
+STARTTEST
+:so small.vim
+/^{/+1
+:set noai tw=2 fo=t
+gRa b\e
+ENDTEST
+
+{
+    
+
+}
+
+STARTTEST
+/^{/+1
+:set ai tw=2 fo=tw
+gqgqjjllab\e
+ENDTEST
+
+{
+a  b  
+
+a    
+}
+
+STARTTEST
+/^{/+1
+:set tw=3 fo=t
+gqgqo
+a \16\ 1\e
+ENDTEST
+
+{
+a \ 1
+}
+
+STARTTEST
+/^{/+1
+:set tw=2 fo=tcq1 comments=:#
+gqgqjgqgqo
+a b
+#a b\e
+ENDTEST
+
+{
+a b
+#a b
+}
+
+STARTTEST
+:g/^STARTTEST/.,/^ENDTEST/d
+:1;/^Results/,$wq! test.out
+ENDTEST
diff --git a/src/testdir/test68.ok b/src/testdir/test68.ok
new file mode 100644 (file)
index 0000000..85f35cf
--- /dev/null
@@ -0,0 +1,35 @@
+Results of test68:
+
+
+{
+a
+b
+}
+
+
+{
+a  
+b  
+
+a  
+b
+}
+
+
+{
+a
+\ 1
+
+a
+\ 1
+}
+
+
+{
+a b
+#a b
+
+a b
+#a b
+}
+
diff --git a/src/testdir/test69.in b/src/testdir/test69.in
new file mode 100644 (file)
index 0000000..578f76b
--- /dev/null
@@ -0,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\e
+ENDTEST
+
+{
+XYZ
+abc XYZ
+}
+
+STARTTEST
+/^{/+1
+:set tw=1 fo=tm
+gqgqjgqgqjgqgqjgqgqjgqgqo
+X
+Xa
+X a
+XY
+X Y\e
+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\e
+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\e
+ENDTEST
+
+{
+  X
+  Xa
+}
+
+STARTTEST
+/^{/+1
+:set noai tw=2 fo=tm
+gqgqjgqgqo
+  X
+  Xa\e
+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\e
+ENDTEST
+
+{
+X
+Xa
+XaY
+XY
+XYZ
+X Y
+X YZ
+XX
+XXa
+XXY
+}
+
+STARTTEST
+/^{/+1
+:set tw=2 fo=tm
+RXa\e
+ENDTEST
+
+{
+
+}
+
+STARTTEST
+:g/^STARTTEST/.,/^ENDTEST/d
+:1;/^Results/,$wq! test.out
+ENDTEST
diff --git a/src/testdir/test69.ok b/src/testdir/test69.ok
new file mode 100644 (file)
index 0000000..3dfe402
--- /dev/null
@@ -0,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
+}
+
index a889332ba345f7634f48650246852a9e3244bbe5..9a7df5d0762e6f01beeefaab4f9d3419230e2e7d 100644 (file)
@@ -681,6 +681,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    301,
 /**/
     300,
 /**/