diff options
Diffstat (limited to 'src/nvim/option.c')
| -rw-r--r-- | src/nvim/option.c | 51 | 
1 files changed, 48 insertions, 3 deletions
| diff --git a/src/nvim/option.c b/src/nvim/option.c index a15c6f4854..b68ee9fd8c 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3552,13 +3552,15 @@ static int get_encoded_char_adv(char_u **p)  /// @return error message, NULL if it's OK.  static char *set_chars_option(win_T *wp, char_u **varp, bool set)  { -  int round, i, len, entries; +  int round, i, len, len2, entries;    char_u *p, *s;    int c1;    int c2 = 0;    int c3 = 0; -  char_u *last_multispace = NULL;  // Last occurrence of "multispace:" -  int multispace_len = 0;          // Length of lcs-multispace string +  char_u *last_multispace = NULL;   // Last occurrence of "multispace:" +  char_u *last_lmultispace = NULL;  // Last occurrence of "leadmultispace:" +  int multispace_len = 0;           // Length of lcs-multispace string +  int lead_multispace_len = 0;      // Length of lcs-leadmultispace string    struct chars_tab {      int *cp;    ///< char value @@ -3646,6 +3648,17 @@ static char *set_chars_option(win_T *wp, char_u **varp, bool set)          } else {            wp->w_p_lcs_chars.multispace = NULL;          } + +        if (wp->w_p_lcs_chars.leadmultispace != NULL) { +          xfree(wp->w_p_lcs_chars.leadmultispace); +        } +        if (lead_multispace_len > 0) { +          wp->w_p_lcs_chars.leadmultispace +            = xmalloc(((size_t)lead_multispace_len + 1) * sizeof(int)); +          wp->w_p_lcs_chars.leadmultispace[lead_multispace_len] = NUL; +        } else { +          wp->w_p_lcs_chars.leadmultispace = NULL; +        }        }      }      p = *varp; @@ -3694,6 +3707,7 @@ static char *set_chars_option(win_T *wp, char_u **varp, bool set)        if (i == entries) {          len = (int)STRLEN("multispace"); +        len2 = (int)STRLEN("leadmultispace");          if ((varp == &p_lcs || varp == &wp->w_p_lcs)              && STRNCMP(p, "multispace", len) == 0              && p[len] == ':' @@ -3725,6 +3739,37 @@ static char *set_chars_option(win_T *wp, char_u **varp, bool set)              }              p = s;            } +        } else if ((varp == &p_lcs || varp == &wp->w_p_lcs) +                   && STRNCMP(p, "leadmultispace", len2) == 0 +                   && p[len2] == ':' +                   && p[len2 + 1] != NUL) { +          s = p + len2 + 1; +          if (round == 0) { +            // Get length of lcsmultispace string in first round +            last_lmultispace = p; +            lead_multispace_len = 0; +            while (*s != NUL && *s != ',') { +              c1 = get_encoded_char_adv(&s); +              if (c1 == 0 || char2cells(c1) > 1) { +                return e_invarg; +              } +              lead_multispace_len++; +            } +            if (lead_multispace_len == 0) { +              // lcsmultispace cannot be an empty string +              return e_invarg; +            } +            p = s; +          } else { +            int multispace_pos = 0; +            while (*s != NUL && *s != ',') { +              c1 = get_encoded_char_adv(&s); +              if (p == last_lmultispace) { +                wp->w_p_lcs_chars.leadmultispace[multispace_pos++] = c1; +              } +            } +            p = s; +          }          } else {            return e_invarg;          } | 
