}
else
{
+ int c0;
+
if (p_extra_free != NULL)
{
vim_free(p_extra_free);
/*
* Get a character from the line itself.
*/
- c = *ptr;
+ c0 = c = *ptr;
#ifdef FEAT_MBYTE
if (has_mbyte)
{
/* 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.
/*
* 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;
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