Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clang/lib/Format/ContinuationIndenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,10 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
for (const auto *Prev = &Tok; Prev; Prev = Prev->Previous) {
if (Prev->is(TT_TemplateString) && Prev->opensScope())
return true;
if (Prev->is(TT_TemplateString) && Prev->closesScope())
if (Prev->opensScope() ||
(Prev->is(TT_TemplateString) && Prev->closesScope())) {
break;
}
}
return false;
};
Expand Down
7 changes: 7 additions & 0 deletions clang/unittests/Format/FormatTestJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,13 @@ TEST_F(FormatTestJS, TemplateStringMultiLineExpression) {
" aaaa: aaaaa,\n"
" bbbb: bbbbb,\n"
" })}`;");

verifyFormat("`${\n"
" (\n"
" FOOFOOFOOFOO____FOO_FOO_FO_FOO_FOOO -\n"
" (barbarbarbar____bar_bar_bar_bar_bar_bar +\n"
" bar_bar_bar_barbarbar___bar_bar_bar + 1),\n"
" )}`;\n");
}

TEST_F(FormatTestJS, TemplateStringASI) {
Expand Down
Loading