Mercurial > vim
comparison src/message.c @ 23825:0bd44e94dd14 v8.2.2454
patch 8.2.2454: leading space can not be made visible
Commit: https://github.com/vim/vim/commit/91478ae49a1b2dc1de63821db731a343e855dcc0
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 3 15:58:13 2021 +0100
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 https://github.com/vim/vim/issues/7772)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 03 Feb 2021 16:00:07 +0100 |
parents | 3239b0f3c592 |
children | 0b1f5717dc4d |
comparison
equal
deleted
inserted
replaced
23824:8b7e3139961a | 23825:0bd44e94dd14 |
---|---|
1829 int c_final = 0; | 1829 int c_final = 0; |
1830 char_u *p_extra = NULL; // init to make SASC shut up | 1830 char_u *p_extra = NULL; // init to make SASC shut up |
1831 int n; | 1831 int n; |
1832 int attr = 0; | 1832 int attr = 0; |
1833 char_u *trail = NULL; | 1833 char_u *trail = NULL; |
1834 char_u *lead = NULL; | |
1834 int l; | 1835 int l; |
1835 char_u buf[MB_MAXBYTES + 1]; | 1836 char_u buf[MB_MAXBYTES + 1]; |
1836 | 1837 |
1837 if (curwin->w_p_list) | 1838 if (curwin->w_p_list) |
1838 list = TRUE; | 1839 list = TRUE; |
1839 | 1840 |
1840 // find start of trailing whitespace | 1841 if (list) |
1841 if (list && lcs_trail) | 1842 { |
1842 { | 1843 // find start of trailing whitespace |
1843 trail = s + STRLEN(s); | 1844 if (lcs_trail) |
1844 while (trail > s && VIM_ISWHITE(trail[-1])) | 1845 { |
1845 --trail; | 1846 trail = s + STRLEN(s); |
1847 while (trail > s && VIM_ISWHITE(trail[-1])) | |
1848 --trail; | |
1849 } | |
1850 // find end of leading whitespace | |
1851 if (lcs_lead) | |
1852 { | |
1853 lead = s; | |
1854 while (VIM_ISWHITE(lead[0])) | |
1855 lead++; | |
1856 // in a line full of spaces all of them are treated as trailing | |
1857 if (*lead == NUL) | |
1858 lead = NULL; | |
1859 } | |
1846 } | 1860 } |
1847 | 1861 |
1848 // output a space for an empty line, otherwise the line will be | 1862 // output a space for an empty line, otherwise the line will be |
1849 // overwritten | 1863 // overwritten |
1850 if (*s == NUL && !(list && lcs_eol != NUL)) | 1864 if (*s == NUL && !(list && lcs_eol != NUL)) |
1934 c_extra = NUL; | 1948 c_extra = NUL; |
1935 c_final = NUL; | 1949 c_final = NUL; |
1936 c = *p_extra++; | 1950 c = *p_extra++; |
1937 // Use special coloring to be able to distinguish <hex> from | 1951 // Use special coloring to be able to distinguish <hex> from |
1938 // the same in plain text. | 1952 // the same in plain text. |
1953 attr = HL_ATTR(HLF_8); | |
1954 } | |
1955 else if (c == ' ' && lead != NULL && s <= lead) | |
1956 { | |
1957 c = lcs_lead; | |
1939 attr = HL_ATTR(HLF_8); | 1958 attr = HL_ATTR(HLF_8); |
1940 } | 1959 } |
1941 else if (c == ' ' && trail != NULL && s > trail) | 1960 else if (c == ' ' && trail != NULL && s > trail) |
1942 { | 1961 { |
1943 c = lcs_trail; | 1962 c = lcs_trail; |