forked from OSchip/llvm-project
clang-format: Fix indenting corner case with comment and else.
Before: if (a) { f(); } // or else .. else { g(); } After: if (a) { f(); } // or else .. else { g(); } llvm-svn: 193684
This commit is contained in:
parent
9885784d67
commit
16fc754216
|
@ -391,7 +391,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
|
|||
State.Column = State.Stack.back().Indent;
|
||||
// Ensure that we fall back to the continuation indent width instead of just
|
||||
// flushing continuations left.
|
||||
if (State.Column == State.FirstIndent)
|
||||
if (State.Column == State.FirstIndent &&
|
||||
PreviousNonComment->isNot(tok::r_brace))
|
||||
State.Column += Style.ContinuationIndentWidth;
|
||||
}
|
||||
|
||||
|
|
|
@ -374,6 +374,13 @@ TEST_F(FormatTest, ElseIf) {
|
|||
" g();\n"
|
||||
"else\n"
|
||||
" h();");
|
||||
verifyFormat("if (a) {\n"
|
||||
" f();\n"
|
||||
"}\n"
|
||||
"// or else ..\n"
|
||||
"else {\n"
|
||||
" g()\n"
|
||||
"}");
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, FormatsForLoop) {
|
||||
|
|
Loading…
Reference in New Issue