diff options
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.h | 6 | ||||
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.h b/clang/lib/Format/ContinuationIndenter.h index 36691d945b4..1da6bd95f10 100644 --- a/clang/lib/Format/ContinuationIndenter.h +++ b/clang/lib/Format/ContinuationIndenter.h @@ -297,11 +297,11 @@ struct ParenState { if (VariablePos != Other.VariablePos) return VariablePos < Other.VariablePos; if (ContainsLineBreak != Other.ContainsLineBreak) - return ContainsLineBreak < Other.ContainsLineBreak; + return ContainsLineBreak; if (ContainsUnwrappedBuilder != Other.ContainsUnwrappedBuilder) - return ContainsUnwrappedBuilder < Other.ContainsUnwrappedBuilder; + return ContainsUnwrappedBuilder; if (NestedBlockInlined != Other.NestedBlockInlined) - return NestedBlockInlined < Other.NestedBlockInlined; + return NestedBlockInlined; return false; } }; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 6565ed2b7b3..78e6103bfcd 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2109,6 +2109,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, const FormatToken &Right) { const FormatToken &Left = *Right.Previous; + // Language-specific stuff. if (Style.Language == FormatStyle::LK_Java) { if (Left.isOneOf(Keywords.kw_throws, Keywords.kw_extends, Keywords.kw_implements)) @@ -2116,6 +2117,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, if (Right.isOneOf(Keywords.kw_throws, Keywords.kw_extends, Keywords.kw_implements)) return true; + } else if (Style.Language == FormatStyle::LK_JavaScript) { + if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace)) + return false; } if (Left.is(tok::at)) |