diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-12-07 21:08:49 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-12-07 21:08:49 +0100 |
commit | 539328197c51c1586cbbb6b6be3db3c412249b49 (patch) | |
tree | a3da5f68060890ad7d890cad60dd79c4d989ded8 /src/misc1.c | |
parent | 10ccaa17ec8b2be1132fd19059e1cd5fb5c902c4 (diff) | |
download | vim-git-539328197c51c1586cbbb6b6be3db3c412249b49.tar.gz |
patch 8.1.0570: 'commentstring' not used when adding fold markerv8.1.0570
Problem: 'commentstring' not used when adding fold marker. (Maxim Kim)
Solution: Only use empty 'comments' middle when leader is empty. (Christian
Brabandt, closes #3670)
Diffstat (limited to 'src/misc1.c')
-rw-r--r-- | src/misc1.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/misc1.c b/src/misc1.c index b1cc21549..d8e7e1acc 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -1993,6 +1993,7 @@ get_last_leader_offset(char_u *line, char_u **flags) for (list = curbuf->b_p_com; *list; ) { char_u *flags_save = list; + int is_only_whitespace = FALSE; /* * Get one option part into part_buf[]. Advance list to next one. @@ -2018,8 +2019,10 @@ get_last_leader_offset(char_u *line, char_u **flags) { if (i == 0 || !VIM_ISWHITE(line[i - 1])) continue; - while (VIM_ISWHITE(string[0])) + while (VIM_ISWHITE(*string)) ++string; + if (*string == NUL) + is_only_whitespace = TRUE; } for (j = 0; string[j] != NUL && string[j] == line[i + j]; ++j) /* do nothing */; @@ -2032,8 +2035,17 @@ get_last_leader_offset(char_u *line, char_u **flags) */ if (vim_strchr(part_buf, COM_BLANK) != NULL && !VIM_ISWHITE(line[i + j]) && line[i + j] != NUL) - { continue; + + // For a middlepart comment that is only white space, only consider + // it to match if everything before the current position in the + // line is also whitespace. + if (is_only_whitespace && vim_strchr(part_buf, COM_MIDDLE) != NULL) + { + for (j = 0; VIM_ISWHITE(line[j]) && j <= i; j++) + ; + if (j < i) + continue; } /* |