diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 9a12392644f..40cb764f292 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -619,7 +619,7 @@ namespace ts.formatting { } function isJsxExpressionContext(context: FormattingContext): boolean { - return context.contextNode.kind === SyntaxKind.JsxExpression; + return context.contextNode.kind === SyntaxKind.JsxExpression || context.contextNode.kind === SyntaxKind.JsxSpreadAttribute; } function isNextTokenParentJsxAttribute(context: FormattingContext): boolean { diff --git a/tests/cases/fourslash/formattingOptionsChangeJsx.ts b/tests/cases/fourslash/formattingOptionsChangeJsx.ts index a3c7e28a1ef..363b53fe81c 100644 --- a/tests/cases/fourslash/formattingOptionsChangeJsx.ts +++ b/tests/cases/fourslash/formattingOptionsChangeJsx.ts @@ -1,14 +1,21 @@ /// //@Filename: file.tsx -/////*InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces*/; +/////*1*/; +//// +//// -runTest("InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces", ";", ";"); +runTest("1", ";", ";"); +runTest("2", " { ...this._getButtonProps() }", " {...this._getButtonProps()}"); -function runTest(propertyName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) { +function runTest(markerName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) { + const propertyName = "InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"; + // Go to the correct file - goTo.marker(propertyName); + goTo.marker(markerName); // Set the option to false first format.setOption(propertyName, false); @@ -17,7 +24,7 @@ function runTest(propertyName: string, expectedStringWhenTrue: string, expectedS format.document(); // Verify - goTo.marker(propertyName); + goTo.marker(markerName); verify.currentLineContentIs(expectedStringWhenFalse); // Set the option to true @@ -27,6 +34,6 @@ function runTest(propertyName: string, expectedStringWhenTrue: string, expectedS format.document(); // Verify - goTo.marker(propertyName); + goTo.marker(markerName); verify.currentLineContentIs(expectedStringWhenTrue); } \ No newline at end of file