Previously we would format
call(
p);
as
call(
p);
with MaxEmptyLinesToKeep == 0.
Now we format it as:
call(p);
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243429
91177308-0d34-0410-b5e6-
96231b3b80d8
bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
const FormatToken &Right) {
const FormatToken &Left = *Right.Previous;
- if (Right.NewlinesBefore > 1)
+ if (Right.NewlinesBefore > 1 && Style.MaxEmptyLinesToKeep > 0)
return true;
if (Style.Language == FormatStyle::LK_JavaScript) {
format("#define A \"some text other\";", AlignLeft));
}
+TEST_F(FormatTest, FullyRemoveEmptyLines) {
+ FormatStyle NoEmptyLines = getLLVMStyleWithColumns(80);
+ NoEmptyLines.MaxEmptyLinesToKeep = 0;
+ EXPECT_EQ("int i = a(b());",
+ format("int i=a(\n\n b(\n\n\n )\n\n);", NoEmptyLines));
+}
+
TEST_F(FormatTest, BreaksStringLiteralsWithTabs) {
EXPECT_EQ(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"