mirror of
https://github.com/neovim/neovim.git
synced 2026-03-30 20:32:08 +00:00
vim-patch:9.2.0102: 'listchars' "leadtab" not used in :list (#38142)
Problem: 'listchars' "leadtab" not used in :list (after 9.2.0088).
Solution: Also check for "leadtab" when using :list. Fix memory leak on
E1572 if "multispace" or "leadmultispace" is set (zeertzjq).
closes: vim/vim#19557
5845741d69
This commit is contained in:
@@ -2101,7 +2101,9 @@ void msg_prt_line(const char *s, bool list)
|
||||
}
|
||||
}
|
||||
// find end of leading whitespace
|
||||
if (curwin->w_p_lcs_chars.lead || curwin->w_p_lcs_chars.leadmultispace != NULL) {
|
||||
if (curwin->w_p_lcs_chars.lead
|
||||
|| curwin->w_p_lcs_chars.leadmultispace != NULL
|
||||
|| curwin->w_p_lcs_chars.leadtab1 != NUL) {
|
||||
lead = s;
|
||||
while (ascii_iswhite(lead[0])) {
|
||||
lead++;
|
||||
@@ -2169,11 +2171,18 @@ void msg_prt_line(const char *s, bool list)
|
||||
sc = schar_from_ascii(' ');
|
||||
sc_extra = schar_from_ascii(' ');
|
||||
} else {
|
||||
sc = (n_extra == 0 && curwin->w_p_lcs_chars.tab3)
|
||||
? curwin->w_p_lcs_chars.tab3
|
||||
: curwin->w_p_lcs_chars.tab1;
|
||||
sc_extra = curwin->w_p_lcs_chars.tab2;
|
||||
sc_final = curwin->w_p_lcs_chars.tab3;
|
||||
schar_T lcs_tab1 = curwin->w_p_lcs_chars.tab1;
|
||||
schar_T lcs_tab2 = curwin->w_p_lcs_chars.tab2;
|
||||
schar_T lcs_tab3 = curwin->w_p_lcs_chars.tab3;
|
||||
// check if leadtab is set in 'listchars'
|
||||
if (lead != NULL && s <= lead && curwin->w_p_lcs_chars.leadtab1 != NUL) {
|
||||
lcs_tab1 = curwin->w_p_lcs_chars.leadtab1;
|
||||
lcs_tab2 = curwin->w_p_lcs_chars.leadtab2;
|
||||
lcs_tab3 = curwin->w_p_lcs_chars.leadtab3;
|
||||
}
|
||||
sc = (n_extra == 0 && lcs_tab3) ? lcs_tab3 : lcs_tab1;
|
||||
sc_extra = lcs_tab2;
|
||||
sc_final = lcs_tab3;
|
||||
hl_id = HLF_0;
|
||||
}
|
||||
} else if (c == NUL && list && curwin->w_p_lcs_chars.eol != NUL) {
|
||||
|
||||
@@ -2313,6 +2313,8 @@ const char *set_chars_option(win_T *wp, const char *value, CharsOption what, boo
|
||||
|
||||
// first round: check for valid value, second round: assign values
|
||||
for (int round = 0; round <= (apply ? 1 : 0); round++) {
|
||||
bool has_tab = false, has_leadtab = false;
|
||||
|
||||
if (round > 0) {
|
||||
// After checking that the value is valid: set defaults
|
||||
for (int i = 0; i < entries; i++) {
|
||||
@@ -2456,6 +2458,11 @@ const char *set_chars_option(win_T *wp, const char *value, CharsOption what, boo
|
||||
tab[i].name.data);
|
||||
}
|
||||
}
|
||||
if (tab[i].cp == &lcs_chars.tab2) {
|
||||
has_tab = true;
|
||||
} else { // tab[i].cp == &lcs_chars.leadtab2
|
||||
has_leadtab = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (*s == ',' || *s == NUL) {
|
||||
@@ -2489,10 +2496,10 @@ const char *set_chars_option(win_T *wp, const char *value, CharsOption what, boo
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (what == kListchars && lcs_chars.leadtab2 != NUL && lcs_chars.tab2 == NUL) {
|
||||
return e_leadtab_requires_tab;
|
||||
if (what == kListchars && has_leadtab && !has_tab) {
|
||||
return e_leadtab_requires_tab;
|
||||
}
|
||||
}
|
||||
|
||||
if (apply) {
|
||||
|
||||
@@ -276,11 +276,13 @@ let test_values = {
|
||||
"\ " ['xxx', ':none', 'xxx:', 'x:non', 'y:mok3', 'z:kittty']],
|
||||
\ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
|
||||
\ 'lispoptions': [['', 'expr:0', 'expr:1'], ['xxx', 'expr:x', 'expr:']],
|
||||
\ 'listchars': [['', 'eol:x', 'tab:xy', 'tab:xyz', 'space:x',
|
||||
\ 'multispace:xxxy', 'lead:x', 'tab:xy,leadtab:xyz', 'leadmultispace:xxxy',
|
||||
\ 'trail:x', 'extends:x', 'precedes:x', 'conceal:x', 'nbsp:x',
|
||||
\ 'eol:\\x24', 'eol:\\u21b5', 'eol:\\U000021b5', 'eol:x,space:y'],
|
||||
\ ['xxx', 'eol:', 'leadtab:xyz']],
|
||||
\ 'listchars': [['', 'eol:x', 'tab:xy', 'tab:xyz', 'space:x', 'lead:x',
|
||||
\ 'multispace:xxxy', 'tab:xy,leadtab:xyz', 'leadtab:xyz,tab:xy',
|
||||
\ 'leadmultispace:xxxy', 'trail:x', 'extends:x', 'precedes:x',
|
||||
\ 'conceal:x', 'eol:\\x24', 'eol:\\u21b5', 'eol:\\U000021b5',
|
||||
\ 'eol:x,space:y', 'nbsp:x'],
|
||||
\ ['xxx', 'eol:', 'leadtab:xyz', 'multispace:xxxy,leadtab:xyz',
|
||||
\ 'leadmultispace:xxxy,leadtab:xyz,multispace:yyyx']],
|
||||
\ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
|
||||
\ 'maxsearchcount': [[1, 10, 100, 1000], [0, -1, 10000]],
|
||||
\ 'messagesopt': [['hit-enter,history:1', 'hit-enter,history:10000',
|
||||
|
||||
@@ -392,6 +392,8 @@ func Test_listchars()
|
||||
\ 'text>---tab '
|
||||
\ ]
|
||||
call Check_listchars(expected, 3, 20)
|
||||
call assert_equal(expected->mapnew({_, s -> trim(s, ' ', 2)}) + [' '],
|
||||
\ split(execute("%list"), "\n"))
|
||||
|
||||
" Test leadtab with unicode characters
|
||||
normal ggdG
|
||||
@@ -399,6 +401,7 @@ func Test_listchars()
|
||||
call append(0, ["\ttext"])
|
||||
let expected = ['├──────┤text']
|
||||
call Check_listchars(expected, 1, 12)
|
||||
call assert_equal(expected + [' '], split(execute("%list"), "\n"))
|
||||
|
||||
" Test leadtab with mixed indentation (spaces + tabs)
|
||||
normal ggdG
|
||||
@@ -406,6 +409,7 @@ func Test_listchars()
|
||||
call append(0, [" \t text"])
|
||||
let expected = ['.+******.text']
|
||||
call Check_listchars(expected, 1, 13)
|
||||
call assert_equal(expected + [' '], split(execute("%list"), "\n"))
|
||||
|
||||
" Test leadtab with pipe character
|
||||
normal ggdG
|
||||
@@ -413,6 +417,7 @@ func Test_listchars()
|
||||
call append(0, ["\ttext"])
|
||||
let expected = ['| text']
|
||||
call Check_listchars(expected, 1, 12)
|
||||
call assert_equal(expected + [' '], split(execute("%list"), "\n"))
|
||||
|
||||
" Test leadtab with unicode bar
|
||||
normal ggdG
|
||||
@@ -420,6 +425,7 @@ func Test_listchars()
|
||||
call append(0, ["\ttext"])
|
||||
let expected = ['│ text']
|
||||
call Check_listchars(expected, 1, 12)
|
||||
call assert_equal(expected + [' '], split(execute("%list"), "\n"))
|
||||
|
||||
" Test leadtab vs tab distinction (leading vs non-leading)
|
||||
" In a line with only tabs, they aren't considered leading.
|
||||
@@ -438,6 +444,8 @@ func Test_listchars()
|
||||
\ '>------->------- '
|
||||
\ ]
|
||||
call Check_listchars(expected, 4, 32)
|
||||
call assert_equal(expected->mapnew({_, s -> trim(s, ' ', 2)}) + [' '],
|
||||
\ split(execute("%list"), "\n"))
|
||||
|
||||
" Test leadtab with trail and space
|
||||
normal ggdG
|
||||
@@ -453,6 +461,8 @@ func Test_listchars()
|
||||
\ '+*******..text<<'
|
||||
\ ]
|
||||
call Check_listchars(expected, 3, 16)
|
||||
call assert_equal(expected->mapnew({_, s -> trim(s, ' ', 2)}) + [' '],
|
||||
\ split(execute("%list"), "\n"))
|
||||
|
||||
" Test leadtab with eol
|
||||
normal ggdG
|
||||
@@ -463,7 +473,8 @@ func Test_listchars()
|
||||
\ 'text>---tab$ '
|
||||
\ ]
|
||||
call Check_listchars(expected, 2, 13)
|
||||
|
||||
call assert_equal(expected->mapnew({_, s -> trim(s, ' ', 2)}) + ['$'],
|
||||
\ split(execute("%list"), "\n"))
|
||||
|
||||
" test nbsp
|
||||
normal ggdG
|
||||
|
||||
Reference in New Issue
Block a user