@@ -389,7 +389,7 @@ namespace ts.formatting {
389
389
390
390
let indentation = inheritedIndentation ;
391
391
if ( indentation === Constants . Unknown ) {
392
- if ( isIndentPreventedChildNode ( parent . kind , node . kind ) ) {
392
+ if ( isIndentPreventedCoreComponent ( node . kind ) ) {
393
393
indentation = parentDynamicIndentation . getIndentation ( ) ;
394
394
}
395
395
else if ( isSomeBlock ( node . kind ) ) {
@@ -479,21 +479,12 @@ namespace ts.formatting {
479
479
return indentation ;
480
480
}
481
481
}
482
- switch ( kind ) {
483
- // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent
484
- case SyntaxKind . OpenBraceToken :
485
- case SyntaxKind . CloseBraceToken :
486
- case SyntaxKind . OpenBracketToken :
487
- case SyntaxKind . CloseBracketToken :
488
- case SyntaxKind . OpenParenToken :
489
- case SyntaxKind . CloseParenToken :
490
- case SyntaxKind . ElseKeyword :
491
- case SyntaxKind . WhileKeyword :
492
- case SyntaxKind . AtToken :
493
- return indentation ;
494
- default :
495
- // if token line equals to the line of containing node (this is a first token in the node) - use node indentation
496
- return nodeStartLine !== line ? indentation + delta : indentation ;
482
+ if ( isIndentPreventedCoreComponent ( kind ) ) {
483
+ return indentation ;
484
+ }
485
+ else {
486
+ // if token line equals to the line of containing node (this is a first token in the node) - use node indentation
487
+ return nodeStartLine !== line ? indentation + delta : indentation ;
497
488
}
498
489
} ,
499
490
getIndentation : ( ) => indentation ,
@@ -1021,11 +1012,20 @@ namespace ts.formatting {
1021
1012
return false ;
1022
1013
}
1023
1014
1024
- function isIndentPreventedChildNode ( parent : SyntaxKind , child : SyntaxKind ) {
1025
- switch ( parent ) {
1026
- case SyntaxKind . JsxElement : {
1027
- return child === SyntaxKind . JsxClosingElement ;
1028
- }
1015
+ function isIndentPreventedCoreComponent ( child : SyntaxKind ) {
1016
+ switch ( child ) {
1017
+ // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent
1018
+ case SyntaxKind . OpenBraceToken :
1019
+ case SyntaxKind . CloseBraceToken :
1020
+ case SyntaxKind . OpenBracketToken :
1021
+ case SyntaxKind . CloseBracketToken :
1022
+ case SyntaxKind . OpenParenToken :
1023
+ case SyntaxKind . CloseParenToken :
1024
+ case SyntaxKind . ElseKeyword :
1025
+ case SyntaxKind . WhileKeyword :
1026
+ case SyntaxKind . AtToken :
1027
+ case SyntaxKind . JsxClosingElement :
1028
+ return true ;
1029
1029
}
1030
1030
}
1031
1031
0 commit comments