@@ -316,7 +316,7 @@ namespace ts.formatting {
316316
317317 // Add a space between statements. All keywords except (do,else,case) has open/close parens after them.
318318 // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any]
319- this . SpaceBetweenStatements = new Rule ( RuleDescriptor . create4 ( Shared . TokenRange . FromTokens ( [ SyntaxKind . CloseParenToken , SyntaxKind . DoKeyword , SyntaxKind . ElseKeyword , SyntaxKind . CaseKeyword ] ) , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext , Rules . IsNotForContext ) , RuleAction . Space ) ) ;
319+ this . SpaceBetweenStatements = new Rule ( RuleDescriptor . create4 ( Shared . TokenRange . FromTokens ( [ SyntaxKind . CloseParenToken , SyntaxKind . DoKeyword , SyntaxKind . ElseKeyword , SyntaxKind . CaseKeyword ] ) , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext , Rules . isNonJsxElementContext , Rules . IsNotForContext ) , RuleAction . Space ) ) ;
320320
321321 // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter.
322322 this . SpaceAfterTryFinally = new Rule ( RuleDescriptor . create2 ( Shared . TokenRange . FromTokens ( [ SyntaxKind . TryKeyword , SyntaxKind . FinallyKeyword ] ) , SyntaxKind . OpenBraceToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext ) , RuleAction . Space ) ) ;
@@ -444,8 +444,8 @@ namespace ts.formatting {
444444 ///
445445
446446 // Insert space after comma delimiter
447- this . SpaceAfterComma = new Rule ( RuleDescriptor . create3 ( SyntaxKind . CommaToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext , Rules . IsNextTokenNotCloseBracket ) , RuleAction . Space ) ) ;
448- this . NoSpaceAfterComma = new Rule ( RuleDescriptor . create3 ( SyntaxKind . CommaToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext ) , RuleAction . Delete ) ) ;
447+ this . SpaceAfterComma = new Rule ( RuleDescriptor . create3 ( SyntaxKind . CommaToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext , Rules . isNonJsxElementContext , Rules . IsNextTokenNotCloseBracket ) , RuleAction . Space ) ) ;
448+ this . NoSpaceAfterComma = new Rule ( RuleDescriptor . create3 ( SyntaxKind . CommaToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext , Rules . isNonJsxElementContext ) , RuleAction . Delete ) ) ;
449449
450450 // Insert space before and after binary operators
451451 this . SpaceBeforeBinaryOperator = new Rule ( RuleDescriptor . create4 ( Shared . TokenRange . Any , Shared . TokenRange . BinaryOperators ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext , Rules . IsBinaryOpContext ) , RuleAction . Space ) ) ;
@@ -723,6 +723,10 @@ namespace ts.formatting {
723723 return context . TokensAreOnSameLine ( ) && context . contextNode . kind !== SyntaxKind . JsxText ;
724724 }
725725
726+ static isNonJsxElementContext ( context : FormattingContext ) : boolean {
727+ return context . contextNode . kind !== SyntaxKind . JsxElement ;
728+ }
729+
726730 static IsNotBeforeBlockInFunctionDeclarationContext ( context : FormattingContext ) : boolean {
727731 return ! Rules . IsFunctionDeclContext ( context ) && ! Rules . IsBeforeBlockContext ( context ) ;
728732 }
0 commit comments