forked from OSchip/llvm-project
Fix aligning of comments that are at the start of the line.
Now correctly leaves: f(); // comment // comment g(); // comment ... alone if the middle comment was aligned with g() before formatting. llvm-svn: 182605
This commit is contained in:
parent
bfe2e5f778
commit
b27375fcd7
|
@ -170,9 +170,10 @@ void WhitespaceManager::alignTrailingComments() {
|
|||
MinColumn = std::max(MinColumn, ChangeMinColumn);
|
||||
MaxColumn = std::min(MaxColumn, ChangeMaxColumn);
|
||||
}
|
||||
BreakBeforeNext =
|
||||
(i == 0) || (Changes[i].NewlinesBefore > 1) ||
|
||||
(Changes[i].NewlinesBefore == 1 && !Changes[i - 1].IsTrailingComment);
|
||||
BreakBeforeNext = (i == 0) || (Changes[i].NewlinesBefore > 1) ||
|
||||
(Changes[i].NewlinesBefore == 1 &&
|
||||
!Changes[i - 1].IsTrailingComment) ||
|
||||
WasAlignedWithStartOfNextLine;
|
||||
Newlines = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -650,6 +650,13 @@ TEST_F(FormatTest, UnderstandsSingleLineComments) {
|
|||
format("lineWith(); // comment\n"
|
||||
" // at start\n"
|
||||
"otherLine();"));
|
||||
|
||||
EXPECT_EQ("lineWith(); // comment\n"
|
||||
"// at start\n"
|
||||
"otherLine(); // comment",
|
||||
format("lineWith(); // comment\n"
|
||||
"// at start\n"
|
||||
"otherLine(); // comment"));
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, CanFormatCommentsLocally) {
|
||||
|
|
Loading…
Reference in New Issue