LevelIndentTracker(const FormatStyle &Style,
const AdditionalKeywords &Keywords, unsigned StartLevel,
int AdditionalIndent)
- : Style(Style), Keywords(Keywords) {
+ : Style(Style), Keywords(Keywords), AdditionalIndent(AdditionalIndent) {
for (unsigned i = 0; i != StartLevel; ++i)
IndentForLevel.push_back(Style.IndentWidth * i + AdditionalIndent);
}
void nextLine(const AnnotatedLine &Line) {
Offset = getIndentOffset(*Line.First);
if (Line.InPPDirective) {
- Indent = Line.Level * Style.IndentWidth;
+ Indent = Line.Level * Style.IndentWidth + AdditionalIndent;
} else {
while (IndentForLevel.size() <= Line.Level)
IndentForLevel.push_back(-1);
const FormatStyle &Style;
const AdditionalKeywords &Keywords;
+ unsigned AdditionalIndent;
+
/// \brief The indent in characters for each level.
std::vector<int> IndentForLevel;
verifyNoCrash("^{v^{a}}");
}
+TEST_F(FormatTest, FormatNestedBlocksInMacros) {
+ EXPECT_EQ("#define MACRO() \\\n"
+ " Debug(aaa, /* force line break */ \\\n"
+ " { \\\n"
+ " int i; \\\n"
+ " int j; \\\n"
+ " })",
+ format("#define MACRO() Debug(aaa, /* force line break */ \\\n"
+ " { int i; int j; })",
+ getGoogleStyle()));
+}
+
TEST_F(FormatTest, IndividualStatementsOfNestedBlocks) {
EXPECT_EQ("DEBUG({\n"
" int i;\n"