diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-06-09 19:08:19 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-06-09 19:08:19 +0000 |
| commit | 798321d8eb5630cd4a8f490a4f25e32ef195fb07 (patch) | |
| tree | a59f5569ef36d00388c0428426abef26aa9105b6 /lib/Format/ContinuationIndenter.cpp | |
| parent | 5e20cdd81c44a443562a09007668ffdf76c455af (diff) | |
Diffstat (limited to 'lib/Format/ContinuationIndenter.cpp')
| -rw-r--r-- | lib/Format/ContinuationIndenter.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 4e8f5af263d2f..91bc64b2b8b4e 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -159,7 +159,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { if (((Previous.is(TT_DictLiteral) && Previous.is(tok::l_brace)) || Previous.is(TT_ArrayInitializerLSquare)) && Style.ColumnLimit > 0 && - getLengthToMatchingParen(Previous) + State.Column > getColumnLimit(State)) + getLengthToMatchingParen(Previous) + State.Column - 1 > + getColumnLimit(State)) return true; if (Current.is(TT_CtorInitializerColon) && ((Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All) || @@ -328,7 +329,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, State.Column > getNewLineColumn(State)) State.Stack.back().ContainsUnwrappedBuilder = true; - if (Current.is(TT_LambdaArrow)) + if (Current.is(TT_LambdaArrow) && Style.Language == FormatStyle::LK_Java) State.Stack.back().NoLineBreak = true; if (Current.isMemberAccess() && Previous.is(tok::r_paren) && (Previous.MatchingParen && @@ -462,6 +463,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, if (NextNonComment->is(tok::question) || (PreviousNonComment && PreviousNonComment->is(tok::question))) State.Stack.back().BreakBeforeParameter = true; + if (Current.is(TT_BinaryOperator) && Current.CanBreakBefore) + State.Stack.back().BreakBeforeParameter = false; if (!DryRun) { unsigned Newlines = std::max( @@ -481,11 +484,9 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, bool NestedBlockSpecialCase = Current.is(tok::r_brace) && State.Stack.size() > 1 && State.Stack[State.Stack.size() - 2].NestedBlockInlined; - if (!NestedBlockSpecialCase) { - for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i) { + if (!NestedBlockSpecialCase) + for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i) State.Stack[i].BreakBeforeParameter = true; - } - } if (PreviousNonComment && !PreviousNonComment->isOneOf(tok::comma, tok::semi) && @@ -689,11 +690,9 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State, // }, a, b, c); if (Current.isNot(tok::comment) && Previous && Previous->is(tok::l_brace) && State.Stack.size() > 1) { - if (State.Stack[State.Stack.size() - 2].NestedBlockInlined && Newline) { - for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i) { + if (State.Stack[State.Stack.size() - 2].NestedBlockInlined && Newline) + for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i) State.Stack[i].NoLineBreak = true; - } - } State.Stack[State.Stack.size() - 2].NestedBlockInlined = false; } if (Previous && (Previous->isOneOf(tok::l_paren, tok::comma, tok::colon) || |
