diff options
author | zeertzjq <zeertzjq@outlook.com> | 2021-03-30 09:26:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-29 21:26:11 -0400 |
commit | f89bfa68692540c2a28794297ce2ab63892de410 (patch) | |
tree | 663ec8254eb7e5ecae1fb00b22bf2511052d8b42 /src/nvim/message.c | |
parent | 291f1ece7f66b16155ad4d418d04be42c45df8ea (diff) | |
download | rneovim-f89bfa68692540c2a28794297ce2ab63892de410.tar.gz rneovim-f89bfa68692540c2a28794297ce2ab63892de410.tar.bz2 rneovim-f89bfa68692540c2a28794297ce2ab63892de410.zip |
vim-patch:8.2.2454: leading space can not be made visible (#14138)
Problem: Leading space can not be made visible.
Solution: Add "lead:" to 'listchars'. (closes vim/vim#7772)
https://github.com/vim/vim/commit/91478ae49a1b2dc1de63821db731a343e855dcc0
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r-- | src/nvim/message.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index cdac4b602a..dea6696f55 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1705,6 +1705,7 @@ void msg_prt_line(char_u *s, int list) char_u *p_extra = NULL; // init to make SASC shut up int n; int attr = 0; + char_u *lead = NULL; char_u *trail = NULL; int l; @@ -1712,11 +1713,24 @@ void msg_prt_line(char_u *s, int list) list = true; } - // find start of trailing whitespace - if (list && curwin->w_p_lcs_chars.trail) { - trail = s + STRLEN(s); - while (trail > s && ascii_iswhite(trail[-1])) { - trail--; + if (list) { + // find start of trailing whitespace + if (curwin->w_p_lcs_chars.trail) { + trail = s + STRLEN(s); + while (trail > s && ascii_iswhite(trail[-1])) { + trail--; + } + } + // find end of leading whitespace + if (curwin->w_p_lcs_chars.lead) { + lead = s; + while (ascii_iswhite(lead[0])) { + lead++; + } + // in a line full of spaces all of them are treated as trailing + if (*lead == NUL) { + lead = NULL; + } } } @@ -1793,6 +1807,9 @@ void msg_prt_line(char_u *s, int list) /* Use special coloring to be able to distinguish <hex> from * the same in plain text. */ attr = HL_ATTR(HLF_8); + } else if (c == ' ' && lead != NULL && s <= lead) { + c = curwin->w_p_lcs_chars.lead; + attr = HL_ATTR(HLF_8); } else if (c == ' ' && trail != NULL && s > trail) { c = curwin->w_p_lcs_chars.trail; attr = HL_ATTR(HLF_8); |