// The minimum level of consecutive lines that have been formatted.
unsigned RangeMinLevel = UINT_MAX;
- // The level of the previous line.
- unsigned PreviousLineLevel = Lines.front()->Level;
for (const AnnotatedLine *Line =
Joiner.getNextMergedLine(DryRun, IndentTracker);
// remaining file if it currently missing a closing brace.
bool ContinueFormatting =
TheLine.Level > RangeMinLevel ||
- (TheLine.Level == RangeMinLevel && PreviousLineLevel <= TheLine.Level);
- PreviousLineLevel = TheLine.Level;
+ (TheLine.Level == RangeMinLevel && !TheLine.startsWith(tok::r_brace));
bool FixIndentation = (FixBadIndentation || ContinueFormatting) &&
Indent != TheLine.First->OriginalColumn;
0, 0));
}
+TEST_F(FormatTestSelective, WrongIndent) {
+ EXPECT_EQ("namespace {\n"
+ "int i;\n"
+ "int j;\n"
+ "}",
+ format("namespace {\n"
+ " int i;\n" // Format here.
+ " int j;\n"
+ "}",
+ 15, 0));
+ EXPECT_EQ("namespace {\n"
+ " int i;\n"
+ " int j;\n"
+ "}",
+ format("namespace {\n"
+ " int i;\n"
+ " int j;\n" // Format here.
+ "}",
+ 24, 0));
+}
+
TEST_F(FormatTestSelective, AlwaysFormatsEntireMacroDefinitions) {
Style.AlignEscapedNewlinesLeft = true;
EXPECT_EQ("int i;\n"