To: vim-dev@vim.org Subject: Patch 6.1.001 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.001 Problem: When formatting UTF-8 text it might be wrapped at a space that is followed by a composing character. (Raphael Finkel) Also correct a display error for removing a composing char on top of a space. Solution: Check for a composing character on a space. Files: src/edit.c, src/misc1.c, src/screen.c *** ../vim-6.1/src/edit.c Sun Mar 24 19:23:31 2002 --- src/edit.c Wed Mar 27 19:25:13 2002 *************** *** 3669,3674 **** --- 3669,3680 ---- # define ISSPECIAL(c) ((c) < ' ' || (c) >= DEL || (c) == '0' || (c) == '^') #endif + #ifdef FEAT_MBYTE + # define WHITECHAR(cc) (vim_iswhite(cc) && (!enc_utf8 || !utf_iscomposing(utf_ptr2char(ml_get_cursor() + 1)))) + #else + # define WHITECHAR(cc) vim_iswhite(cc) + #endif + void insertchar(c, flags, second_indent) int c; /* character to insert or NUL */ *************** *** 3814,3831 **** || curwin->w_cursor.col >= Insstart.col) { cc = gchar_cursor(); ! if (vim_iswhite(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 && vim_iswhite(cc)) { dec_cursor(); cc = gchar_cursor(); } ! if (curwin->w_cursor.col == 0 && vim_iswhite(cc)) break; /* only spaces in front of text */ #ifdef FEAT_COMMENTS /* Don't break until after the comment leader */ --- 3820,3837 ---- || 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)) { dec_cursor(); cc = gchar_cursor(); } ! if (curwin->w_cursor.col == 0 && WHITECHAR(cc)) break; /* only spaces in front of text */ #ifdef FEAT_COMMENTS /* Don't break until after the comment leader */ *************** *** 3842,3848 **** dec_cursor(); cc = gchar_cursor(); ! if (vim_iswhite(cc)) continue; /* one-letter, continue */ curwin->w_cursor.col = col; } --- 3848,3854 ---- dec_cursor(); cc = gchar_cursor(); ! if (WHITECHAR(cc)) continue; /* one-letter, continue */ curwin->w_cursor.col = col; } *************** *** 3899,3905 **** * characters that will remain on top line */ curwin->w_cursor.col = foundcol; ! while (cc = gchar_cursor(), vim_iswhite(cc)) inc_cursor(); startcol -= curwin->w_cursor.col; if (startcol < 0) --- 3905,3911 ---- * 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) *** ../vim-6.1/src/misc1.c Sun Mar 24 19:23:31 2002 --- src/misc1.c Wed Mar 27 19:31:45 2002 *************** *** 931,937 **** replace_push(NUL); /* end of extra blanks */ if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES)) { ! while (*p_extra == ' ' || *p_extra == '\t') { if (REPLACE_NORMAL(State)) replace_push(*p_extra); --- 931,942 ---- replace_push(NUL); /* end of extra blanks */ if (curbuf->b_p_ai || (flags & OPENLINE_DELSPACES)) { ! while ((*p_extra == ' ' || *p_extra == '\t') ! #ifdef FEAT_MBYTE ! && (!enc_utf8 ! || !utf_iscomposing(utf_ptr2char(p_extra + 1))) ! #endif ! ) { if (REPLACE_NORMAL(State)) replace_push(*p_extra); *** ../vim-6.1/src/screen.c Sun Mar 24 19:23:32 2002 --- src/screen.c Thu Mar 28 20:19:23 2002 *************** *** 3991,3997 **** if (clear_width > 0) { while (col <= endcol && ScreenLines[off_to] == ' ' ! && ScreenAttrs[off_to] == 0) { ++off_to; ++col; --- 3991,4001 ---- if (clear_width > 0) { while (col <= endcol && ScreenLines[off_to] == ' ' ! && ScreenAttrs[off_to] == 0 ! #ifdef FEAT_MBYTE ! && (!enc_utf8 || ScreenLinesUC[off_to] == 0) ! #endif ! ) { ++off_to; ++col; *************** *** 4220,4226 **** /* blank out the rest of the line */ while (col < clear_width && ScreenLines[off_to] == ' ' ! && ScreenAttrs[off_to] == 0) { ++off_to; ++col; --- 4224,4234 ---- /* blank out the rest of the line */ while (col < clear_width && ScreenLines[off_to] == ' ' ! && ScreenAttrs[off_to] == 0 ! #ifdef FEAT_MBYTE ! && (!enc_utf8 || ScreenLinesUC[off_to] == 0) ! #endif ! ) { ++off_to; ++col; *************** *** 5841,5849 **** end_off = LineOffset[row] + end_col; /* skip blanks (used often, keep it fast!) */ ! while (off < end_off && ScreenLines[off] == ' ' && ScreenAttrs[off] == 0) ! ++off; if (off < end_off) /* something to be cleared */ { col = off - LineOffset[row]; --- 5849,5864 ---- end_off = LineOffset[row] + end_col; /* skip blanks (used often, keep it fast!) */ ! #ifdef FEAT_MBYTE ! if (enc_utf8) ! while (off < end_off && ScreenLines[off] == ' ' ! && ScreenAttrs[off] == 0 && ScreenLinesUC[off] == 0) ! ++off; ! else ! #endif ! while (off < end_off && ScreenLines[off] == ' ' && ScreenAttrs[off] == 0) ! ++off; if (off < end_off) /* something to be cleared */ { col = off - LineOffset[row]; *** ../vim-6.1/src/version.c Sun Mar 24 19:23:35 2002 --- src/version.c Sat Mar 30 16:51:28 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 1, /**/ -- Time is an illusion. Lunchtime doubly so. -- Ford Prefect, in Douglas Adams' "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///