mirror of
https://github.com/neovim/neovim.git
synced 2025-10-10 03:46:31 +00:00
vim-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 vim/vim#1456)
38632faf63
This commit is contained in:
@@ -3143,14 +3143,15 @@ win_line (
|
||||
}
|
||||
--n_extra;
|
||||
} else {
|
||||
int c0;
|
||||
|
||||
if (p_extra_free != NULL) {
|
||||
xfree(p_extra_free);
|
||||
p_extra_free = NULL;
|
||||
}
|
||||
/*
|
||||
* Get a character from the line itself.
|
||||
*/
|
||||
c = *ptr;
|
||||
|
||||
// Get a character from the line itself.
|
||||
c0 = c = *ptr;
|
||||
if (has_mbyte) {
|
||||
mb_c = c;
|
||||
if (enc_utf8) {
|
||||
@@ -3160,11 +3161,12 @@ win_line (
|
||||
mb_utf8 = FALSE;
|
||||
if (mb_l > 1) {
|
||||
mb_c = utfc_ptr2char(ptr, u8cc);
|
||||
/* Overlong encoded ASCII or ASCII with composing char
|
||||
* is displayed normally, except a NUL. */
|
||||
if (mb_c < 0x80)
|
||||
c = mb_c;
|
||||
mb_utf8 = TRUE;
|
||||
// Overlong encoded ASCII or ASCII with composing char
|
||||
// is displayed normally, except a NUL.
|
||||
if (mb_c < 0x80) {
|
||||
c0 = c = mb_c;
|
||||
}
|
||||
mb_utf8 = true;
|
||||
|
||||
/* At start of the line we can have a composing char.
|
||||
* Draw it as a space with a composing char. */
|
||||
@@ -3428,10 +3430,8 @@ win_line (
|
||||
char_attr = hl_combine_attr(char_attr, term_attrs[vcol]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Found last space before word: check for line break.
|
||||
*/
|
||||
if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)) {
|
||||
// Found last space before word: check for line break.
|
||||
if (wp->w_p_lbr && c0 == c && vim_isbreak(c) && !vim_isbreak(*ptr)) {
|
||||
int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0;
|
||||
char_u *p = ptr - (mb_off + 1);
|
||||
// TODO: is passing p for start of the line OK?
|
||||
|
@@ -194,6 +194,33 @@ func Test_multibyte_sign_and_colorcolumn()
|
||||
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
|
||||
|
||||
func Test_chinese_char_on_wrap_column()
|
||||
call s:test_windows("setl nolbr wrap sbr=")
|
||||
syntax off
|
||||
|
Reference in New Issue
Block a user