Skip to content

Commit 38632fa

Browse files
committed
patch 8.0.0380: with 'linebreak' double wide char wraps badly
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)
1 parent 74a4716 commit 38632fa

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

src/screen.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4189,6 +4189,8 @@ win_line(
41894189
}
41904190
else
41914191
{
4192+
int c0;
4193+
41924194
if (p_extra_free != NULL)
41934195
{
41944196
vim_free(p_extra_free);
@@ -4197,7 +4199,7 @@ win_line(
41974199
/*
41984200
* Get a character from the line itself.
41994201
*/
4200-
c = *ptr;
4202+
c0 = c = *ptr;
42014203
#ifdef FEAT_MBYTE
42024204
if (has_mbyte)
42034205
{
@@ -4214,7 +4216,7 @@ win_line(
42144216
/* Overlong encoded ASCII or ASCII with composing char
42154217
* is displayed normally, except a NUL. */
42164218
if (mb_c < 0x80)
4217-
c = mb_c;
4219+
c0 = c = mb_c;
42184220
mb_utf8 = TRUE;
42194221

42204222
/* At start of the line we can have a composing char.
@@ -4538,7 +4540,8 @@ win_line(
45384540
/*
45394541
* Found last space before word: check for line break.
45404542
*/
4541-
if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr))
4543+
if (wp->w_p_lbr && c0 == c
4544+
&& vim_isbreak(c) && !vim_isbreak(*ptr))
45424545
{
45434546
# ifdef FEAT_MBYTE
45444547
int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0;

src/testdir/test_listlbr_utf8.vim

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,30 @@ func Test_multibyte_sign_and_colorcolumn()
193193
call s:compare_lines(expect, lines)
194194
call s:close_windows()
195195
endfunc
196+
197+
func Test_illegal_byte_and_breakat()
198+
call s:test_windows("setl sbr= brk+=<")
199+
vert resize 18
200+
call setline(1, repeat("\x80", 6))
201+
redraw!
202+
let lines = s:screen_lines([1, 2], winwidth(0))
203+
let expect = [
204+
\ "<80><80><80><80><8",
205+
\ "0><80> ",
206+
\ ]
207+
call s:compare_lines(expect, lines)
208+
call s:close_windows('setl brk&vim')
209+
endfunc
210+
211+
func Test_multibyte_wrap_and_breakat()
212+
call s:test_windows("setl sbr= brk+=>")
213+
call setline(1, repeat('a', 17) . repeat('', 2))
214+
redraw!
215+
let lines = s:screen_lines([1, 2], winwidth(0))
216+
let expect = [
217+
\ "aaaaaaaaaaaaaaaaaあ>",
218+
\ "",
219+
\ ]
220+
call s:compare_lines(expect, lines)
221+
call s:close_windows('setl brk&vim')
222+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
380,
767769
/**/
768770
379,
769771
/**/

0 commit comments

Comments
 (0)