continue;
// Ignore layouts that are bound to violate the column limit.
- if (Format.TotalWidth > Style.ColumnLimit)
+ if (Format.TotalWidth > Style.ColumnLimit && Columns > 1)
continue;
Formats.push_back(Format);
I = Formats.rbegin(),
E = Formats.rend();
I != E; ++I) {
- if (I->TotalWidth <= RemainingCharacters) {
+ if (I->TotalWidth <= RemainingCharacters || I->Columns == 1) {
if (BestFormat && I->LineCount > BestFormat->LineCount)
break;
BestFormat = &*I;
" 1, 22, 333, 4444, 55555, 666666, 7777777,\n"
" 1, 22, 333, 4444, 55555, 666666, 7777777,\n"
" 1, 22, 333, 4444, 55555, 666666, 7777777});");
+
+ // Allow "single-column" layout even if that violates the column limit. There
+ // isn't going to be a better way.
+ verifyFormat("std::vector<int> a = {\n"
+ " aaaaaaaa,\n"
+ " aaaaaaaa,\n"
+ " aaaaaaaa,\n"
+ " aaaaaaaa,\n"
+ " aaaaaaaaaa,\n"
+ " aaaaaaaa,\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaa};",
+ getLLVMStyleWithColumns(30));
}
TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {