patch 8.2.2454: leading space can not be made visible
Problem: Leading space can not be made visible.
Solution: Add "lead:" to 'listchars'. (closes #7772)
diff --git a/src/message.c b/src/message.c
index e4f96d0..8adc224 100644
--- a/src/message.c
+++ b/src/message.c
@@ -1831,18 +1831,32 @@
int n;
int attr = 0;
char_u *trail = NULL;
+ char_u *lead = NULL;
int l;
char_u buf[MB_MAXBYTES + 1];
if (curwin->w_p_list)
list = TRUE;
- // find start of trailing whitespace
- if (list && lcs_trail)
+ if (list)
{
- trail = s + STRLEN(s);
- while (trail > s && VIM_ISWHITE(trail[-1]))
- --trail;
+ // find start of trailing whitespace
+ if (lcs_trail)
+ {
+ trail = s + STRLEN(s);
+ while (trail > s && VIM_ISWHITE(trail[-1]))
+ --trail;
+ }
+ // find end of leading whitespace
+ if (lcs_lead)
+ {
+ lead = s;
+ while (VIM_ISWHITE(lead[0]))
+ lead++;
+ // in a line full of spaces all of them are treated as trailing
+ if (*lead == NUL)
+ lead = NULL;
+ }
}
// output a space for an empty line, otherwise the line will be
@@ -1938,6 +1952,11 @@
// the same in plain text.
attr = HL_ATTR(HLF_8);
}
+ else if (c == ' ' && lead != NULL && s <= lead)
+ {
+ c = lcs_lead;
+ attr = HL_ATTR(HLF_8);
+ }
else if (c == ' ' && trail != NULL && s > trail)
{
c = lcs_trail;