Mercurial > vim
comparison src/drawline.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 | 00548e40e708 |
children | 6793853063e5 |
comparison
equal
deleted
inserted
replaced
23824:8b7e3139961a | 23825:0bd44e94dd14 |
---|---|
337 hlf_T diff_hlf = (hlf_T)0; // type of diff highlighting | 337 hlf_T diff_hlf = (hlf_T)0; // type of diff highlighting |
338 int change_start = MAXCOL; // first col of changed area | 338 int change_start = MAXCOL; // first col of changed area |
339 int change_end = -1; // last col of changed area | 339 int change_end = -1; // last col of changed area |
340 #endif | 340 #endif |
341 colnr_T trailcol = MAXCOL; // start of trailing spaces | 341 colnr_T trailcol = MAXCOL; // start of trailing spaces |
342 colnr_T leadcol = 0; // start of leading spaces | |
342 #ifdef FEAT_LINEBREAK | 343 #ifdef FEAT_LINEBREAK |
343 int need_showbreak = FALSE; // overlong line, skipping first x | 344 int need_showbreak = FALSE; // overlong line, skipping first x |
344 // chars | 345 // chars |
345 #endif | 346 #endif |
346 #if defined(FEAT_SIGNS) || defined(FEAT_QUICKFIX) \ | 347 #if defined(FEAT_SIGNS) || defined(FEAT_QUICKFIX) \ |
732 } | 733 } |
733 #endif | 734 #endif |
734 | 735 |
735 if (wp->w_p_list) | 736 if (wp->w_p_list) |
736 { | 737 { |
737 if (lcs_space || lcs_trail || lcs_nbsp) | 738 if (lcs_space || lcs_trail || lcs_lead || lcs_nbsp) |
738 extra_check = TRUE; | 739 extra_check = TRUE; |
740 | |
739 // find start of trailing whitespace | 741 // find start of trailing whitespace |
740 if (lcs_trail) | 742 if (lcs_trail) |
741 { | 743 { |
742 trailcol = (colnr_T)STRLEN(ptr); | 744 trailcol = (colnr_T)STRLEN(ptr); |
743 while (trailcol > (colnr_T)0 && VIM_ISWHITE(ptr[trailcol - 1])) | 745 while (trailcol > (colnr_T)0 && VIM_ISWHITE(ptr[trailcol - 1])) |
744 --trailcol; | 746 --trailcol; |
745 trailcol += (colnr_T) (ptr - line); | 747 trailcol += (colnr_T) (ptr - line); |
748 } | |
749 // find end of leading whitespace | |
750 if (lcs_lead) | |
751 { | |
752 leadcol = 0; | |
753 while (VIM_ISWHITE(ptr[leadcol])) | |
754 ++leadcol; | |
755 if (ptr[leadcol] == NUL) | |
756 // in a line full of spaces all of them are treated as trailing | |
757 leadcol = (colnr_T)0; | |
758 else | |
759 // keep track of the first column not filled with spaces | |
760 leadcol += (colnr_T) (ptr - line) + 1; | |
746 } | 761 } |
747 } | 762 } |
748 | 763 |
749 wcr_attr = get_wcr_attr(wp); | 764 wcr_attr = get_wcr_attr(wp); |
750 if (wcr_attr != 0) | 765 if (wcr_attr != 0) |
1990 || (mb_c == 0x202f && mb_l == 3)))) | 2005 || (mb_c == 0x202f && mb_l == 3)))) |
1991 && lcs_nbsp) | 2006 && lcs_nbsp) |
1992 || (c == ' ' | 2007 || (c == ' ' |
1993 && mb_l == 1 | 2008 && mb_l == 1 |
1994 && lcs_space | 2009 && lcs_space |
2010 && ptr - line >= leadcol | |
1995 && ptr - line <= trailcol))) | 2011 && ptr - line <= trailcol))) |
1996 { | 2012 { |
1997 c = (c == ' ') ? lcs_space : lcs_nbsp; | 2013 c = (c == ' ') ? lcs_space : lcs_nbsp; |
1998 if (area_attr == 0 && search_attr == 0) | 2014 if (area_attr == 0 && search_attr == 0) |
1999 { | 2015 { |
2010 } | 2026 } |
2011 else | 2027 else |
2012 mb_utf8 = FALSE; | 2028 mb_utf8 = FALSE; |
2013 } | 2029 } |
2014 | 2030 |
2015 if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ') | 2031 if ((trailcol != MAXCOL && ptr > line + trailcol && c == ' ') |
2016 { | 2032 || (leadcol != 0 && ptr < line + leadcol && c == ' ')) |
2017 c = lcs_trail; | 2033 { |
2034 c = (ptr > line + trailcol) ? lcs_trail : lcs_lead; | |
2018 if (!attr_pri) | 2035 if (!attr_pri) |
2019 { | 2036 { |
2020 n_attr = 1; | 2037 n_attr = 1; |
2021 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_8)); | 2038 extra_attr = hl_combine_attr(win_attr, HL_ATTR(HLF_8)); |
2022 saved_attr2 = char_attr; // save current attr | 2039 saved_attr2 = char_attr; // save current attr |