Now correctly leaves:
f(); // comment
// comment
g(); // comment
... alone if the middle comment was aligned with g() before formatting.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182605
91177308-0d34-0410-b5e6-
96231b3b80d8
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;
}
}
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) {