@@ -389,7 +389,7 @@ namespace ts.formatting {
389389
390390 let indentation = inheritedIndentation ;
391391 if ( indentation === Constants . Unknown ) {
392- if ( isIndentPreventedCoreComponent ( node . kind ) ) {
392+ if ( isIndentPreventedChildNode ( parent . kind , node . kind ) ) {
393393 indentation = parentDynamicIndentation . getIndentation ( ) ;
394394 }
395395 else if ( isSomeBlock ( node . kind ) ) {
@@ -479,12 +479,21 @@ namespace ts.formatting {
479479 return indentation ;
480480 }
481481 }
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 ;
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 ;
488497 }
489498 } ,
490499 getIndentation : ( ) => indentation ,
@@ -1012,6 +1021,14 @@ namespace ts.formatting {
10121021 return false ;
10131022 }
10141023
1024+ function isIndentPreventedChildNode ( parent : SyntaxKind , child : SyntaxKind ) {
1025+ switch ( parent ) {
1026+ case SyntaxKind . JsxElement : {
1027+ return child === SyntaxKind . JsxClosingElement ;
1028+ }
1029+ }
1030+ }
1031+
10151032 function isIndentPreventedCoreComponent ( child : SyntaxKind ) {
10161033 switch ( child ) {
10171034 // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent
@@ -1027,6 +1044,7 @@ namespace ts.formatting {
10271044 case SyntaxKind . JsxClosingElement :
10281045 return true ;
10291046 }
1047+ return false ;
10301048 }
10311049
10321050 function getOpenTokenForList ( node : Node , list : Node [ ] ) {
0 commit comments