mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #22488 from zeertzjq/vim-9.0.1373
vim-patch:9.0.{0690,0691,0991,1373}: listchars fixes
This commit is contained in:
commit
1dd2424b12
@ -1691,12 +1691,9 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
} else if (foldinfo.fi_lines > 0) {
|
} else if (foldinfo.fi_lines > 0) {
|
||||||
// skip writing the buffer line itself
|
// skip writing the buffer line itself
|
||||||
c = NUL;
|
c = NUL;
|
||||||
XFREE_CLEAR(p_extra_free);
|
|
||||||
} else {
|
} else {
|
||||||
int c0;
|
int c0;
|
||||||
|
|
||||||
XFREE_CLEAR(p_extra_free);
|
|
||||||
|
|
||||||
// Get a character from the line itself.
|
// Get a character from the line itself.
|
||||||
c0 = c = (uint8_t)(*ptr);
|
c0 = c = (uint8_t)(*ptr);
|
||||||
mb_c = c;
|
mb_c = c;
|
||||||
@ -2103,42 +2100,45 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
tab_len += n_extra - tab_len;
|
tab_len += n_extra - tab_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If n_extra > 0, it gives the number of chars
|
if (tab_len > 0) {
|
||||||
// to use for a tab, else we need to calculate the width
|
// If n_extra > 0, it gives the number of chars
|
||||||
// for a tab.
|
// to use for a tab, else we need to calculate the
|
||||||
int len = (tab_len * utf_char2len(wp->w_p_lcs_chars.tab2));
|
// width for a tab.
|
||||||
if (wp->w_p_lcs_chars.tab3) {
|
int tab2_len = utf_char2len(wp->w_p_lcs_chars.tab2);
|
||||||
len += utf_char2len(wp->w_p_lcs_chars.tab3);
|
int len = tab_len * tab2_len;
|
||||||
}
|
if (wp->w_p_lcs_chars.tab3) {
|
||||||
if (n_extra > 0) {
|
len += utf_char2len(wp->w_p_lcs_chars.tab3) - tab2_len;
|
||||||
len += n_extra - tab_len;
|
|
||||||
}
|
|
||||||
c = wp->w_p_lcs_chars.tab1;
|
|
||||||
p = xmalloc((size_t)len + 1);
|
|
||||||
memset(p, ' ', (size_t)len);
|
|
||||||
p[len] = NUL;
|
|
||||||
xfree(p_extra_free);
|
|
||||||
p_extra_free = p;
|
|
||||||
for (int i = 0; i < tab_len; i++) {
|
|
||||||
if (*p == NUL) {
|
|
||||||
tab_len = i;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
int lcs = wp->w_p_lcs_chars.tab2;
|
if (n_extra > 0) {
|
||||||
|
len += n_extra - tab_len;
|
||||||
// if tab3 is given, use it for the last char
|
|
||||||
if (wp->w_p_lcs_chars.tab3 && i == tab_len - 1) {
|
|
||||||
lcs = wp->w_p_lcs_chars.tab3;
|
|
||||||
}
|
}
|
||||||
p += utf_char2bytes(lcs, p);
|
c = wp->w_p_lcs_chars.tab1;
|
||||||
n_extra += utf_char2len(lcs) - (saved_nextra > 0 ? 1 : 0);
|
p = xmalloc((size_t)len + 1);
|
||||||
}
|
memset(p, ' ', (size_t)len);
|
||||||
p_extra = p_extra_free;
|
p[len] = NUL;
|
||||||
|
xfree(p_extra_free);
|
||||||
|
p_extra_free = p;
|
||||||
|
for (int i = 0; i < tab_len; i++) {
|
||||||
|
if (*p == NUL) {
|
||||||
|
tab_len = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
int lcs = wp->w_p_lcs_chars.tab2;
|
||||||
|
|
||||||
// n_extra will be increased by FIX_FOX_BOGUSCOLS
|
// if tab3 is given, use it for the last char
|
||||||
// macro below, so need to adjust for that here
|
if (wp->w_p_lcs_chars.tab3 && i == tab_len - 1) {
|
||||||
if (vcol_off > 0) {
|
lcs = wp->w_p_lcs_chars.tab3;
|
||||||
n_extra -= vcol_off;
|
}
|
||||||
|
p += utf_char2bytes(lcs, p);
|
||||||
|
n_extra += utf_char2len(lcs) - (saved_nextra > 0 ? 1 : 0);
|
||||||
|
}
|
||||||
|
p_extra = p_extra_free;
|
||||||
|
|
||||||
|
// n_extra will be increased by FIX_FOX_BOGUSCOLS
|
||||||
|
// macro below, so need to adjust for that here
|
||||||
|
if (vcol_off > 0) {
|
||||||
|
n_extra -= vcol_off;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2167,7 +2167,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
|||||||
c = (n_extra == 0 && wp->w_p_lcs_chars.tab3)
|
c = (n_extra == 0 && wp->w_p_lcs_chars.tab3)
|
||||||
? wp->w_p_lcs_chars.tab3
|
? wp->w_p_lcs_chars.tab3
|
||||||
: wp->w_p_lcs_chars.tab1;
|
: wp->w_p_lcs_chars.tab1;
|
||||||
if (wp->w_p_lbr) {
|
if (wp->w_p_lbr && p_extra != NULL && *p_extra != NUL) {
|
||||||
c_extra = NUL; // using p_extra from above
|
c_extra = NUL; // using p_extra from above
|
||||||
} else {
|
} else {
|
||||||
c_extra = wp->w_p_lcs_chars.tab2;
|
c_extra = wp->w_p_lcs_chars.tab2;
|
||||||
|
@ -1075,4 +1075,22 @@ func Test_breakindent_column()
|
|||||||
bwipeout!
|
bwipeout!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_linebreak_list()
|
||||||
|
" This was setting wlv.c_extra to NUL while wlv.p_extra is NULL
|
||||||
|
filetype plugin on
|
||||||
|
syntax enable
|
||||||
|
edit! $VIMRUNTIME/doc/index.txt
|
||||||
|
/v_P
|
||||||
|
|
||||||
|
setlocal list
|
||||||
|
setlocal listchars=tab:>-
|
||||||
|
setlocal linebreak
|
||||||
|
setlocal nowrap
|
||||||
|
setlocal filetype=help
|
||||||
|
redraw!
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -73,6 +73,30 @@ func Test_linebreak_with_nolist()
|
|||||||
call s:close_windows()
|
call s:close_windows()
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_linebreak_with_list_and_number()
|
||||||
|
call s:test_windows('setl list listchars+=tab:>-')
|
||||||
|
call setline(1, ["abcdefg\thijklmnopqrstu", "v"])
|
||||||
|
let lines = s:screen_lines([1, 4], winwidth(0))
|
||||||
|
let expect_nonumber = [
|
||||||
|
\ "abcdefg>------------",
|
||||||
|
\ "hijklmnopqrstu$ ",
|
||||||
|
\ "v$ ",
|
||||||
|
\ "~ ",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect_nonumber, lines)
|
||||||
|
|
||||||
|
setl number
|
||||||
|
let lines = s:screen_lines([1, 4], winwidth(0))
|
||||||
|
let expect_number = [
|
||||||
|
\ " 1 abcdefg>--------",
|
||||||
|
\ " hijklmnopqrstu$ ",
|
||||||
|
\ " 2 v$ ",
|
||||||
|
\ "~ ",
|
||||||
|
\ ]
|
||||||
|
call s:compare_lines(expect_number, lines)
|
||||||
|
call s:close_windows()
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_should_break()
|
func Test_should_break()
|
||||||
call s:test_windows('setl sbr=+ nolist')
|
call s:test_windows('setl sbr=+ nolist')
|
||||||
call setline(1, "1\t" . repeat('a', winwidth(0)-2))
|
call setline(1, "1\t" . repeat('a', winwidth(0)-2))
|
||||||
|
Loading…
Reference in New Issue
Block a user