@@ -389,7 +389,7 @@ namespace ts.formatting {
389389
390390 let indentation = inheritedIndentation ;
391391 if ( indentation === Constants . Unknown ) {
392- if ( isIndentPreventedChildNode ( parent . kind , node . kind ) ) {
392+ if ( isIndentPreventedCoreComponent ( node . kind ) ) {
393393 indentation = parentDynamicIndentation . getIndentation ( ) ;
394394 }
395395 else if ( isSomeBlock ( node . kind ) ) {
@@ -479,21 +479,12 @@ namespace ts.formatting {
479479 return indentation ;
480480 }
481481 }
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 ;
497488 }
498489 } ,
499490 getIndentation : ( ) => indentation ,
@@ -1021,11 +1012,20 @@ namespace ts.formatting {
10211012 return false ;
10221013 }
10231014
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 ;
10291029 }
10301030 }
10311031
0 commit comments