@@ -292,10 +292,10 @@ namespace ts.formatting {
292
292
this . SpaceBeforeOpenBraceInControl = new Rule ( RuleDescriptor . create2 ( this . ControlOpenBraceLeftTokenRange , SyntaxKind . OpenBraceToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsControlDeclContext , Rules . IsNotFormatOnEnter , Rules . IsSameLineTokenOrBeforeMultilineBlockContext ) , RuleAction . Space ) , RuleFlags . CanDeleteNewLines ) ;
293
293
294
294
// Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}.
295
- this . SpaceAfterOpenBrace = new Rule ( RuleDescriptor . create3 ( SyntaxKind . OpenBraceToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsSingleLineBlockContext ) , RuleAction . Space ) ) ;
296
- this . SpaceBeforeCloseBrace = new Rule ( RuleDescriptor . create2 ( Shared . TokenRange . Any , SyntaxKind . CloseBraceToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsSingleLineBlockContext ) , RuleAction . Space ) ) ;
297
- this . NoSpaceAfterOpenBrace = new Rule ( RuleDescriptor . create3 ( SyntaxKind . OpenBraceToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsSingleLineBlockContext ) , RuleAction . Delete ) ) ;
298
- this . NoSpaceBeforeCloseBrace = new Rule ( RuleDescriptor . create2 ( Shared . TokenRange . Any , SyntaxKind . CloseBraceToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsSingleLineBlockContext ) , RuleAction . Delete ) ) ;
295
+ this . SpaceAfterOpenBrace = new Rule ( RuleDescriptor . create3 ( SyntaxKind . OpenBraceToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsBraceWrappedContext ) , RuleAction . Space ) ) ;
296
+ this . SpaceBeforeCloseBrace = new Rule ( RuleDescriptor . create2 ( Shared . TokenRange . Any , SyntaxKind . CloseBraceToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsBraceWrappedContext ) , RuleAction . Space ) ) ;
297
+ this . NoSpaceAfterOpenBrace = new Rule ( RuleDescriptor . create3 ( SyntaxKind . OpenBraceToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsBraceWrappedContext ) , RuleAction . Delete ) ) ;
298
+ this . NoSpaceBeforeCloseBrace = new Rule ( RuleDescriptor . create2 ( Shared . TokenRange . Any , SyntaxKind . CloseBraceToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsBraceWrappedContext ) , RuleAction . Delete ) ) ;
299
299
this . NoSpaceBetweenEmptyBraceBrackets = new Rule ( RuleDescriptor . create1 ( SyntaxKind . OpenBraceToken , SyntaxKind . CloseBraceToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsNonJsxSameLineTokenContext , Rules . IsObjectContext ) , RuleAction . Delete ) ) ;
300
300
301
301
// Insert new line after { and before } in multi-line contexts.
@@ -615,6 +615,10 @@ namespace ts.formatting {
615
615
return context . TokensAreOnSameLine ( ) || Rules . IsBeforeMultilineBlockContext ( context ) ;
616
616
}
617
617
618
+ static IsBraceWrappedContext ( context : FormattingContext ) : boolean {
619
+ return context . contextNode . kind === SyntaxKind . ObjectBindingPattern || Rules . IsSingleLineBlockContext ( context ) ;
620
+ }
621
+
618
622
// This check is done before an open brace in a control construct, a function, or a typescript block declaration
619
623
static IsBeforeMultilineBlockContext ( context : FormattingContext ) : boolean {
620
624
return Rules . IsBeforeBlockContext ( context ) && ! ( context . NextNodeAllOnSameLine ( ) || context . NextNodeBlockIsOnOneLine ( ) ) ;
0 commit comments