From 67eabb98bc83c8be4b28068c8489d295d7e6ec36 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Fri, 5 Jan 2018 08:57:27 +0800 Subject: [PATCH] fix #20449, insert space between decorators (#20491) --- src/services/formatting/rules.ts | 2 +- tests/cases/fourslash/formattingDecorators.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index bf1c57b218..9a12392644 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -198,7 +198,7 @@ namespace ts.formatting { RuleAction.Delete), // decorators - rule("SpaceBeforeAt", anyToken, SyntaxKind.AtToken, [isNonJsxSameLineTokenContext], RuleAction.Space), + rule("SpaceBeforeAt", [SyntaxKind.CloseParenToken, SyntaxKind.Identifier], SyntaxKind.AtToken, [isNonJsxSameLineTokenContext], RuleAction.Space), rule("NoSpaceAfterAt", SyntaxKind.AtToken, anyToken, [isNonJsxSameLineTokenContext], RuleAction.Delete), // Insert space after @ in decorator rule("SpaceAfterDecorator", diff --git a/tests/cases/fourslash/formattingDecorators.ts b/tests/cases/fourslash/formattingDecorators.ts index 366b9cb772..9ff6de3cf1 100644 --- a/tests/cases/fourslash/formattingDecorators.ts +++ b/tests/cases/fourslash/formattingDecorators.ts @@ -41,6 +41,8 @@ /////*29*/ property1; //// /////*30*/ @ decorator33 @ decorator34 @decorator35 property2; +/////*31*/function test(@decorator36@decorator37 param) {}; +/////*32*/function test2(@decorator38()@decorator39()param) {}; ////} format.document(); @@ -103,4 +105,8 @@ verify.currentLineContentIs(" @decorator32"); goTo.marker("29"); verify.currentLineContentIs(" property1;"); goTo.marker("30"); -verify.currentLineContentIs(" @decorator33 @decorator34 @decorator35 property2;"); \ No newline at end of file +verify.currentLineContentIs(" @decorator33 @decorator34 @decorator35 property2;"); +goTo.marker("31"); +verify.currentLineContentIs("function test(@decorator36 @decorator37 param) { };"); +goTo.marker("32"); +verify.currentLineContentIs("function test2(@decorator38() @decorator39() param) { };"); \ No newline at end of file