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