mirror of
https://github.com/neovim/neovim.git
synced 2024-12-26 14:11:15 -07:00
vim-patch:8.1.1868: multi-byte chars in 'listchars' fail with 'linebreak' set
Problem: Multibyte characters in 'listchars' don't work correctly if
'linebreak' is also enabled. (Martin Tournoij)
Solution: Make it work correctly. (Christian Brabandt, closes vim/vim#4822,
closes vim/vim#4812)
69cbbecf54
This commit is contained in:
parent
9897ad3606
commit
13b6f7a806
@ -3647,8 +3647,9 @@ win_line (
|
||||
tab_len += n_extra - tab_len;
|
||||
}
|
||||
|
||||
/* if n_extra > 0, it gives the number of chars to use for
|
||||
* a tab, else we need to calculate the width for a tab */
|
||||
// if n_extra > 0, it gives the number of chars
|
||||
// to use for a tab, else we need to calculate the width
|
||||
// for a tab
|
||||
int len = (tab_len * mb_char2len(wp->w_p_lcs_chars.tab2));
|
||||
if (n_extra > 0) {
|
||||
len += n_extra - tab_len;
|
||||
@ -3660,10 +3661,16 @@ win_line (
|
||||
xfree(p_extra_free);
|
||||
p_extra_free = p;
|
||||
for (i = 0; i < tab_len; i++) {
|
||||
utf_char2bytes(wp->w_p_lcs_chars.tab2, p);
|
||||
p += mb_char2len(wp->w_p_lcs_chars.tab2);
|
||||
n_extra += mb_char2len(wp->w_p_lcs_chars.tab2)
|
||||
- (saved_nextra > 0 ? 1: 0);
|
||||
int lcs = wp->w_p_lcs_chars.tab2;
|
||||
|
||||
// if tab3 is given, need to change the char
|
||||
// for tab
|
||||
if (wp->w_p_lcs_chars.tab3 && i == tab_len - 1) {
|
||||
lcs = wp->w_p_lcs_chars.tab3;
|
||||
}
|
||||
utf_char2bytes(lcs, p);
|
||||
p += mb_char2len(lcs);
|
||||
n_extra += mb_char2len(lcs) - (saved_nextra > 0 ? 1 : 0);
|
||||
}
|
||||
p_extra = p_extra_free;
|
||||
|
||||
|
@ -58,6 +58,26 @@ func Test_listchars()
|
||||
call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
|
||||
endfor
|
||||
|
||||
" tab with 3rd character and linebreak set
|
||||
set listchars-=tab:<=>
|
||||
set listchars+=tab:<·>
|
||||
set linebreak
|
||||
let expected = [
|
||||
\ '<······>aa<····>$',
|
||||
\ '..bb<··>--$',
|
||||
\ '...cccc>-$',
|
||||
\ 'dd........ee--<>$',
|
||||
\ '-$'
|
||||
\ ]
|
||||
redraw!
|
||||
for i in range(1, 5)
|
||||
call cursor(i, 1)
|
||||
call assert_equal([expected[i - 1]], ScreenLines(i, virtcol('$')))
|
||||
endfor
|
||||
set nolinebreak
|
||||
set listchars-=tab:<·>
|
||||
set listchars+=tab:<=>
|
||||
|
||||
set listchars-=trail:-
|
||||
let expected = [
|
||||
\ '<======>aa<====>$',
|
||||
|
Loading…
Reference in New Issue
Block a user