summaryrefslogtreecommitdiff
path: root/src/misc1.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-12-09 15:00:52 +0100
committerBram Moolenaar <Bram@vim.org>2018-12-09 15:00:52 +0100
commit4af7259b2b35e85c590d54908fcd248d2c733be8 (patch)
tree5df9467836d8ec86c789c519b639abbdf8c803c7 /src/misc1.c
parent55d46913084745a48749d7ac4f48930852e1d87e (diff)
downloadvim-git-4af7259b2b35e85c590d54908fcd248d2c733be8.tar.gz
patch 8.1.0574: 'commentstring' not used when adding fold marker in Cv8.1.0574
Problem: 'commentstring' not used when adding fold marker in C. Solution: Require white space before middle comment part. (mostly by Hirohito Higashi)
Diffstat (limited to 'src/misc1.c')
-rw-r--r--src/misc1.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/misc1.c b/src/misc1.c
index d8e7e1acc..f1f007478 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -1993,7 +1993,6 @@ 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.
@@ -2021,8 +2020,6 @@ get_last_leader_offset(char_u *line, char_u **flags)
continue;
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 */;
@@ -2037,11 +2034,13 @@ get_last_leader_offset(char_u *line, char_u **flags)
&& !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)
+ if (vim_strchr(part_buf, COM_MIDDLE) != NULL)
{
+ // For a middlepart comment, only consider it to match if
+ // everything before the current position in the line is
+ // whitespace. Otherwise we would think we are inside a
+ // comment if the middle part appears somewhere in the middle
+ // of the line. E.g. for C the "*" appears often.
for (j = 0; VIM_ISWHITE(line[j]) && j <= i; j++)
;
if (j < i)