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: #19557
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
}
// find end of leading whitespace
if (curwin->w_lcs_chars.lead
- || curwin->w_lcs_chars.leadmultispace != NULL)
+ || curwin->w_lcs_chars.leadmultispace != NULL
+ || curwin->w_lcs_chars.leadtab1 != NUL)
{
lead = s;
while (VIM_ISWHITE(lead[0]))
}
else
{
- c = (n_extra == 0 && curwin->w_lcs_chars.tab3)
- ? curwin->w_lcs_chars.tab3
- : curwin->w_lcs_chars.tab1;
- c_extra = curwin->w_lcs_chars.tab2;
- c_final = curwin->w_lcs_chars.tab3;
+ int lcs_tab1 = curwin->w_lcs_chars.tab1;
+ int lcs_tab2 = curwin->w_lcs_chars.tab2;
+ int lcs_tab3 = curwin->w_lcs_chars.tab3;
+
+ // check if leadtab is set in 'listchars'
+ if (lead != NULL && s <= lead
+ && curwin->w_lcs_chars.leadtab1 != NUL)
+ {
+ lcs_tab1 = curwin->w_lcs_chars.leadtab1;
+ lcs_tab2 = curwin->w_lcs_chars.leadtab2;
+ lcs_tab3 = curwin->w_lcs_chars.leadtab3;
+ }
+
+ c = (n_extra == 0 && lcs_tab3) ? lcs_tab3 : lcs_tab1;
+ c_extra = lcs_tab2;
+ c_final = lcs_tab3;
attr = HL_ATTR(HLF_8);
}
}
// first round: check for valid value, second round: assign values
for (round = 0; round <= (apply ? 1 : 0); ++round)
{
+ int has_tab = FALSE, has_leadtab = FALSE;
+
if (round > 0)
{
// After checking that the value is valid: set defaults.
e_wrong_character_width_for_field_str,
tab[i].name.string);
}
+ 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 (*p == ',')
++p;
}
- }
- if (is_listchars && lcs_chars.leadtab2 != NUL && lcs_chars.tab2 == NUL)
- return e_leadtab_requires_tab;
+ if (is_listchars && has_leadtab && !has_tab)
+ return e_leadtab_requires_tab;
+ }
if (apply)
{
\ '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
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
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
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
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.
\ '>------->------- '
\ ]
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
\ '+*******..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
\ '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
\ ['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',
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 102,
/**/
101,
/**/