Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp =================================================================== --- cfe/trunk/lib/Format/ContinuationIndenter.cpp +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp @@ -661,9 +661,7 @@ // before the corresponding } or ]. if (PreviousNonComment && (PreviousNonComment->isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) || - opensProtoMessageField(*PreviousNonComment, Style) || - (PreviousNonComment->is(TT_TemplateString) && - PreviousNonComment->opensScope()))) + opensProtoMessageField(*PreviousNonComment, Style))) State.Stack.back().BreakBeforeClosingBrace = true; if (State.Stack.back().AvoidBinPacking) { @@ -925,11 +923,6 @@ moveStatePastFakeLParens(State, Newline); moveStatePastScopeCloser(State); - if (Current.is(TT_TemplateString) && Current.opensScope()) - State.Stack.back().LastSpace = - (Current.IsMultiline ? Current.LastLineColumnWidth - : State.Column + Current.ColumnWidth) - - strlen("${"); bool CanBreakProtrudingToken = !State.Stack.back().NoLineBreak && !State.Stack.back().NoLineBreakInOperand; moveStatePastScopeOpener(State, Newline); @@ -1101,18 +1094,6 @@ LastSpace = std::max(LastSpace, State.Stack.back().Indent); } - // JavaScript template strings are special as we always want to indent - // nested expressions relative to the ${}. Otherwise, this can create quite - // a mess. - if (Current.is(TT_TemplateString)) { - unsigned Column = Current.IsMultiline - ? Current.LastLineColumnWidth - : State.Column + Current.ColumnWidth; - NewIndent = Column; - LastSpace = Column; - NestedBlockIndent = Column; - } - bool EndsInComma = Current.MatchingParen && Current.MatchingParen->getPreviousNonComment() && Index: cfe/trunk/unittests/Format/FormatTestJS.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -1793,32 +1793,28 @@ verifyFormat("var x = someFunction(`${})`) //\n" " .oooooooooooooooooon();"); verifyFormat("var x = someFunction(`${aaaa}${\n" - " aaaaa( //\n" - " aaaaa)\n" - " })`);"); + " aaaaa( //\n" + " aaaaa)})`);"); } TEST_F(FormatTestJS, TemplateStringMultiLineExpression) { verifyFormat("var f = `aaaaaaaaaaaaaaaaaa: ${\n" - " aaaaa + //\n" - " bbbb\n" - " }`;", + " aaaaa + //\n" + " bbbb}`;", "var f = `aaaaaaaaaaaaaaaaaa: ${aaaaa + //\n" " bbbb}`;"); verifyFormat("var f = `\n" " aaaaaaaaaaaaaaaaaa: ${\n" - " aaaaa + //\n" - " bbbb\n" - " }`;", + " aaaaa + //\n" + " bbbb}`;", "var f = `\n" " aaaaaaaaaaaaaaaaaa: ${ aaaaa + //\n" " bbbb }`;"); verifyFormat("var f = `\n" " aaaaaaaaaaaaaaaaaa: ${\n" - " someFunction(\n" - " aaaaa + //\n" - " bbbb)\n" - " }`;", + " someFunction(\n" + " aaaaa + //\n" + " bbbb)}`;", "var f = `\n" " aaaaaaaaaaaaaaaaaa: ${someFunction (\n" " aaaaa + //\n" @@ -1827,9 +1823,9 @@ // It might be preferable to wrap before "someFunction". verifyFormat("var f = `\n" " aaaaaaaaaaaaaaaaaa: ${someFunction({\n" - " aaaa: aaaaa,\n" - " bbbb: bbbbb,\n" - " })}`;", + " aaaa: aaaaa,\n" + " bbbb: bbbbb,\n" + "})}`;", "var f = `\n" " aaaaaaaaaaaaaaaaaa: ${someFunction ({\n" " aaaa: aaaaa,\n"