1
0
forked from aniani/vim

patch 8.2.4908: no text formatting for // comment after a statement

Problem:    No text formatting for // comment after a statement.
Solution:   format a comment when the 'c' flag is in 'formatoptions'.
This commit is contained in:
Bram Moolenaar
2022-05-07 15:43:52 +01:00
parent 2bf875f881
commit 48a8a83303
3 changed files with 35 additions and 1 deletions

View File

@@ -104,7 +104,27 @@ internal_format(
// Don't break until after the comment leader
if (do_comments)
leader_len = get_leader_len(ml_get_curline(), NULL, FALSE, TRUE);
{
char_u *line = ml_get_curline();
leader_len = get_leader_len(line, NULL, FALSE, TRUE);
#ifdef FEAT_CINDENT
if (leader_len == 0 && curbuf->b_p_cin)
{
int comment_start;
// Check for a line comment after code.
comment_start = check_linecomment(line);
if (comment_start != MAXCOL)
{
leader_len = get_leader_len(
line + comment_start, NULL, FALSE, TRUE);
if (leader_len != 0)
leader_len += comment_start;
}
}
#endif
}
else
leader_len = 0;