summaryrefslogtreecommitdiffstats
path: root/src/message.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2021-09-10 16:58:30 +0200
committerBram Moolenaar <Bram@vim.org>2021-09-10 16:58:30 +0200
commitf14b8ba1373f569705cb80419248054100b02360 (patch)
tree57858129c7f87dc01ea87fde7f19133ceaaa9c2b /src/message.c
parent07802044b90b2cbcc64b2dfe235f019d7c37589c (diff)
patch 8.2.3424: a sequence of spaces is hard to see in list modev8.2.3424
Problem: A sequence of spaces is hard to see in list mode. Solution: Add the "multispace" option to 'listchars'. (closes #8834)
Diffstat (limited to 'src/message.c')
-rw-r--r--src/message.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/message.c b/src/message.c
index bb0dbb2bd1..0cd09da9f4 100644
--- a/src/message.c
+++ b/src/message.c
@@ -1841,6 +1841,8 @@ msg_prt_line(char_u *s, int list)
int attr = 0;
char_u *trail = NULL;
char_u *lead = NULL;
+ int in_multispace = FALSE;
+ int multispace_pos = 0;
int l;
char_u buf[MB_MAXBYTES + 1];
@@ -1912,6 +1914,10 @@ msg_prt_line(char_u *s, int list)
{
attr = 0;
c = *s++;
+ in_multispace = c == ' '
+ && ((col > 0 && s[-2] == ' ') || *s == ' ');
+ if (!in_multispace)
+ multispace_pos = 0;
if (c == TAB && (!list || curwin->w_lcs_chars.tab1))
{
// tab amount depends on current column
@@ -1963,20 +1969,31 @@ msg_prt_line(char_u *s, int list)
// the same in plain text.
attr = HL_ATTR(HLF_8);
}
- else if (c == ' ' && lead != NULL && s <= lead)
+ else if (c == ' ')
{
- c = curwin->w_lcs_chars.lead;
- attr = HL_ATTR(HLF_8);
- }
- else if (c == ' ' && trail != NULL && s > trail)
- {
- c = curwin->w_lcs_chars.trail;
- attr = HL_ATTR(HLF_8);
- }
- else if (c == ' ' && list && curwin->w_lcs_chars.space != NUL)
- {
- c = curwin->w_lcs_chars.space;
- attr = HL_ATTR(HLF_8);
+ if (lead != NULL && s <= lead)
+ {
+ c = curwin->w_lcs_chars.lead;
+ attr = HL_ATTR(HLF_8);
+ }
+ else if (trail != NULL && s > trail)
+ {
+ c = curwin->w_lcs_chars.trail;
+ attr = HL_ATTR(HLF_8);
+ }
+ else if (list && in_multispace
+ && curwin->w_lcs_chars.multispace != NULL)
+ {
+ c = curwin->w_lcs_chars.multispace[multispace_pos++];
+ if (curwin->w_lcs_chars.multispace[multispace_pos] == NUL)
+ multispace_pos = 0;
+ attr = HL_ATTR(HLF_8);
+ }
+ else if (list && curwin->w_lcs_chars.space != NUL)
+ {
+ c = curwin->w_lcs_chars.space;
+ attr = HL_ATTR(HLF_8);
+ }
}
}