forked from aniani/vim
patch 8.2.3932: C line comment not formatted properly
Problem: C line comment not formatted properly. Solution: If a line comment follows after "#if" the next line is not the end of a paragraph.
This commit is contained in:
parent
febb78fa17
commit
264d3ddac0
@ -223,6 +223,21 @@ func Test_format_c_comment()
|
|||||||
END
|
END
|
||||||
call assert_equal(expected, getline(1, '$'))
|
call assert_equal(expected, getline(1, '$'))
|
||||||
|
|
||||||
|
%del
|
||||||
|
let text =<< trim END
|
||||||
|
#if 0 // This is another long end of
|
||||||
|
// line comment that
|
||||||
|
// wraps.
|
||||||
|
END
|
||||||
|
call setline(1, text)
|
||||||
|
normal gq2j
|
||||||
|
let expected =<< trim END
|
||||||
|
#if 0 // This is another long
|
||||||
|
// end of line comment
|
||||||
|
// that wraps.
|
||||||
|
END
|
||||||
|
call assert_equal(expected, getline(1, '$'))
|
||||||
|
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@ -193,7 +193,8 @@ internal_format(
|
|||||||
if (curwin->w_cursor.col <= (colnr_T)wantcol)
|
if (curwin->w_cursor.col <= (colnr_T)wantcol)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ((cc >= 0x100 || !utf_allow_break_before(cc)) && fo_multibyte)
|
else if ((cc >= 0x100 || !utf_allow_break_before(cc))
|
||||||
|
&& fo_multibyte)
|
||||||
{
|
{
|
||||||
int ncc;
|
int ncc;
|
||||||
int allow_break;
|
int allow_break;
|
||||||
@ -948,7 +949,7 @@ format_lines(
|
|||||||
int leader_len = 0; // leader len of current line
|
int leader_len = 0; // leader len of current line
|
||||||
int next_leader_len; // leader len of next line
|
int next_leader_len; // leader len of next line
|
||||||
char_u *leader_flags = NULL; // flags for leader of current line
|
char_u *leader_flags = NULL; // flags for leader of current line
|
||||||
char_u *next_leader_flags; // flags for leader of next line
|
char_u *next_leader_flags = NULL; // flags for leader of next line
|
||||||
int do_comments; // format comments
|
int do_comments; // format comments
|
||||||
int do_comments_list = 0; // format comments with 'n' or '2'
|
int do_comments_list = 0; // format comments with 'n' or '2'
|
||||||
int advance = TRUE;
|
int advance = TRUE;
|
||||||
@ -1071,7 +1072,15 @@ format_lines(
|
|||||||
|| !same_leader(curwin->w_cursor.lnum,
|
|| !same_leader(curwin->w_cursor.lnum,
|
||||||
leader_len, leader_flags,
|
leader_len, leader_flags,
|
||||||
next_leader_len, next_leader_flags))
|
next_leader_len, next_leader_flags))
|
||||||
|
{
|
||||||
|
// Special case: If the next line starts with a line comment
|
||||||
|
// and this line has a line comment after some text, the
|
||||||
|
// paragraph doesn't really end.
|
||||||
|
if (next_leader_flags == NULL
|
||||||
|
|| STRNCMP(next_leader_flags, "://", 3) != 0
|
||||||
|
|| check_linecomment(ml_get_curline()) == MAXCOL)
|
||||||
is_end_par = TRUE;
|
is_end_par = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// If we have got to the end of a paragraph, or the line is
|
// If we have got to the end of a paragraph, or the line is
|
||||||
// getting long, format it.
|
// getting long, format it.
|
||||||
|
@ -749,6 +749,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3932,
|
||||||
/**/
|
/**/
|
||||||
3931,
|
3931,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user