@@ -815,7 +815,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
815
815
return Tok.is (tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous &&
816
816
Tok.Previous ->is (tok::identifier);
817
817
};
818
- const auto IsInTemplateString = [this ](const FormatToken &Tok) {
818
+ auto IsInTemplateString = [this ](const FormatToken &Tok) {
819
819
if (!Style .isJavaScript ())
820
820
return false ;
821
821
for (const auto *Prev = &Tok; Prev; Prev = Prev->Previous ) {
@@ -827,7 +827,10 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
827
827
return false ;
828
828
};
829
829
// Identifies simple (no expression) one-argument function calls.
830
- const auto IsSimpleFunction = [&](const FormatToken &Tok) {
830
+ auto StartsSimpleOneArgList = [&](const FormatToken &TokAfterLParen) {
831
+ assert (TokAfterLParen.isNot (tok::comment) || TokAfterLParen.Next );
832
+ const auto &Tok =
833
+ TokAfterLParen.is (tok::comment) ? *TokAfterLParen.Next : TokAfterLParen;
831
834
if (!Tok.FakeLParens .empty () && Tok.FakeLParens .back () > prec::Unknown)
832
835
return false ;
833
836
// Nested calls that involve `new` expressions also look like simple
@@ -836,6 +839,11 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
836
839
// - foo(::new Bar())
837
840
if (Tok.is (tok::kw_new) || Tok.startsSequence (tok::coloncolon, tok::kw_new))
838
841
return true ;
842
+ if (Tok.is (TT_UnaryOperator) ||
843
+ (Style .isJavaScript () &&
844
+ Tok.isOneOf (tok::ellipsis, Keywords.kw_await ))) {
845
+ return true ;
846
+ }
839
847
const auto *Previous = Tok.Previous ;
840
848
if (!Previous || (!Previous->isOneOf (TT_FunctionDeclarationLParen,
841
849
TT_LambdaDefinitionLParen) &&
@@ -861,7 +869,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
861
869
// or
862
870
// caaaaaaaaaaaaaaaaaaaaal(
863
871
// new SomethingElseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee());
864
- !IsSimpleFunction (Current)) {
872
+ !StartsSimpleOneArgList (Current)) {
865
873
CurrentState.NoLineBreak = true ;
866
874
}
867
875
0 commit comments