diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -492,9 +492,10 @@ return true; } - // Break after the closing parenthesis of TypeScript decorators. + // Break after the closing parenthesis of TypeScript decorators before `get`. if (Style.Language == FormatStyle::LK_JavaScript && - Previous.is(tok::r_paren) && Previous.is(TT_JavaAnnotation)) { + Current.TokenText == "get" && Previous.is(tok::r_paren) && + Previous.is(TT_JavaAnnotation)) { return true; } diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -701,8 +701,12 @@ getGoogleJSStyleWithColumns(20))); } -TEST_F(FormatTestJS, FormatsDecoratedFunctions) { - // Regression test: ensure that there is a break before `get`. +TEST_F(FormatTestJS, FormatsDecorators) { + // No line break after argument decorators. + verifyFormat("class A {\n" + " constructor(@arg(DECOR) private arg: Type) {}\n" + "}"); + // Ensure that there is a break before `get`. EXPECT_EQ("class A {\n" " private p = () => {}\n" "\n"