]> granicus.if.org Git - vim/commitdiff
patch 8.0.0380: with 'linebreak' double wide char wraps badly v8.0.0380
authorBram Moolenaar <Bram@vim.org>
Sun, 26 Feb 2017 18:40:59 +0000 (19:40 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 26 Feb 2017 18:40:59 +0000 (19:40 +0100)
Problem:    With 'linebreak' set and 'breakat' includes ">" a double-wide
            character results in "<<" displayed.
Solution:   Check for the character not to be replaced. (Ozaki Kiichi,
            closes #1456)

src/screen.c
src/testdir/test_listlbr_utf8.vim
src/version.c

index d801c4cc1641fd44749527cf19c1a00f85d47dc1..cc9c9f6dc5777b7b888abc1099a3cbf43b998bca 100644 (file)
@@ -4189,6 +4189,8 @@ win_line(
        }
        else
        {
+           int c0;
+
            if (p_extra_free != NULL)
            {
                vim_free(p_extra_free);
@@ -4197,7 +4199,7 @@ win_line(
            /*
             * Get a character from the line itself.
             */
-           c = *ptr;
+           c0 = c = *ptr;
 #ifdef FEAT_MBYTE
            if (has_mbyte)
            {
@@ -4214,7 +4216,7 @@ win_line(
                        /* Overlong encoded ASCII or ASCII with composing char
                         * is displayed normally, except a NUL. */
                        if (mb_c < 0x80)
-                           c = mb_c;
+                           c0 = c = mb_c;
                        mb_utf8 = TRUE;
 
                        /* At start of the line we can have a composing char.
@@ -4538,7 +4540,8 @@ win_line(
                /*
                 * Found last space before word: check for line break.
                 */
-               if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr))
+               if (wp->w_p_lbr && c0 == c
+                                     && vim_isbreak(c) && !vim_isbreak(*ptr))
                {
 # ifdef FEAT_MBYTE
                    int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0;
index 807b6ad31a65f9877277e2008b7a948c263e7ee1..99db37ee6c0279cffa5871556ab5c2c68e1ab89b 100644 (file)
@@ -193,3 +193,30 @@ func Test_multibyte_sign_and_colorcolumn()
   call s:compare_lines(expect, lines)
   call s:close_windows()
 endfunc
+
+func Test_illegal_byte_and_breakat()
+  call s:test_windows("setl sbr= brk+=<")
+  vert resize 18
+  call setline(1, repeat("\x80", 6))
+  redraw!
+  let lines = s:screen_lines([1, 2], winwidth(0))
+  let expect = [
+\ "<80><80><80><80><8",
+\ "0><80>            ",
+\ ]
+  call s:compare_lines(expect, lines)
+  call s:close_windows('setl brk&vim')
+endfunc
+
+func Test_multibyte_wrap_and_breakat()
+  call s:test_windows("setl sbr= brk+=>")
+  call setline(1, repeat('a', 17) . repeat('あ', 2))
+  redraw!
+  let lines = s:screen_lines([1, 2], winwidth(0))
+  let expect = [
+\ "aaaaaaaaaaaaaaaaaあ>",
+\ "あ                  ",
+\ ]
+  call s:compare_lines(expect, lines)
+  call s:close_windows('setl brk&vim')
+endfunc
index 21f416950d823d2e4b1f95dc0c16eaaa8e4a1fdf..7408b6df32c3df3e038960561e22b9cbf5c3a520 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    380,
 /**/
     379,
 /**/