mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
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.
264d3ddac0
This commit is contained in:
@@ -6137,8 +6137,7 @@ static void internal_format(int textwidth, int second_indent, int flags, int for
|
|||||||
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))
|
} else if ((cc >= 0x100 || !utf_allow_break_before(cc)) && fo_multibyte) {
|
||||||
&& fo_multibyte) {
|
|
||||||
int ncc;
|
int ncc;
|
||||||
bool allow_break;
|
bool allow_break;
|
||||||
|
|
||||||
|
@@ -4350,7 +4350,7 @@ void format_lines(linenr_T line_count, int avoid_fex)
|
|||||||
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
|
||||||
bool advance = true;
|
bool advance = true;
|
||||||
int second_indent = -1; // indent for second line (comment aware)
|
int second_indent = -1; // indent for second line (comment aware)
|
||||||
bool first_par_line = true;
|
bool first_par_line = true;
|
||||||
@@ -4467,7 +4467,14 @@ void format_lines(linenr_T line_count, int avoid_fex)
|
|||||||
leader_len, leader_flags,
|
leader_len, leader_flags,
|
||||||
next_leader_len,
|
next_leader_len,
|
||||||
next_leader_flags)) {
|
next_leader_flags)) {
|
||||||
is_end_par = true;
|
// 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(get_cursor_line_ptr()) == MAXCOL) {
|
||||||
|
is_end_par = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -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
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user