mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
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:
parent
2bf875f881
commit
48a8a83303
@ -342,6 +342,18 @@ func Test_format_c_comment()
|
||||
END
|
||||
call assert_equal(expected, getline(1, '$'))
|
||||
|
||||
" typing comment text auto-wraps
|
||||
%del
|
||||
call setline(1, text)
|
||||
exe "normal! 2GA blah more text blah.\<Esc>"
|
||||
let expected =<< trim END
|
||||
{
|
||||
val = val; // This is a comment
|
||||
// blah more text
|
||||
// blah.
|
||||
END
|
||||
call assert_equal(expected, getline(1, '$'))
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -746,6 +746,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
4908,
|
||||
/**/
|
||||
4907,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user