@@ -488,14 +488,16 @@ namespace ts.formatting {
488
488
// open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent
489
489
case SyntaxKind . OpenBraceToken :
490
490
case SyntaxKind . CloseBraceToken :
491
- case SyntaxKind . OpenBracketToken :
492
- case SyntaxKind . CloseBracketToken :
493
491
case SyntaxKind . OpenParenToken :
494
492
case SyntaxKind . CloseParenToken :
495
493
case SyntaxKind . ElseKeyword :
496
494
case SyntaxKind . WhileKeyword :
497
495
case SyntaxKind . AtToken :
498
496
return indentation ;
497
+ case SyntaxKind . OpenBracketToken :
498
+ case SyntaxKind . CloseBracketToken :
499
+ return ( container . kind === SyntaxKind . MappedType ) ?
500
+ indentation + getEffectiveDelta ( delta , container ) : indentation ;
499
501
default :
500
502
// if token line equals to the line of containing node (this is a first token in the node) - use node indentation
501
503
return nodeStartLine !== line ? indentation + getEffectiveDelta ( delta , container ) : indentation ;
@@ -566,7 +568,7 @@ namespace ts.formatting {
566
568
if ( tokenInfo . token . end > node . end ) {
567
569
break ;
568
570
}
569
- consumeTokenAndAdvanceScanner ( tokenInfo , node , nodeDynamicIndentation ) ;
571
+ consumeTokenAndAdvanceScanner ( tokenInfo , node , nodeDynamicIndentation , node ) ;
570
572
}
571
573
572
574
function processChildNode (
@@ -617,7 +619,7 @@ namespace ts.formatting {
617
619
break ;
618
620
}
619
621
620
- consumeTokenAndAdvanceScanner ( tokenInfo , node , parentDynamicIndentation ) ;
622
+ consumeTokenAndAdvanceScanner ( tokenInfo , node , parentDynamicIndentation , node ) ;
621
623
}
622
624
623
625
if ( ! formattingScanner . isOnToken ( ) ) {
@@ -673,11 +675,11 @@ namespace ts.formatting {
673
675
computeIndentation ( tokenInfo . token , startLine , Constants . Unknown , parent , parentDynamicIndentation , parentStartLine ) ;
674
676
675
677
listDynamicIndentation = getDynamicIndentation ( parent , parentStartLine , indentation . indentation , indentation . delta ) ;
676
- consumeTokenAndAdvanceScanner ( tokenInfo , parent , listDynamicIndentation ) ;
678
+ consumeTokenAndAdvanceScanner ( tokenInfo , parent , listDynamicIndentation , parent ) ;
677
679
}
678
680
else {
679
681
// consume any tokens that precede the list as child elements of 'node' using its indentation scope
680
- consumeTokenAndAdvanceScanner ( tokenInfo , parent , parentDynamicIndentation ) ;
682
+ consumeTokenAndAdvanceScanner ( tokenInfo , parent , parentDynamicIndentation , parent ) ;
681
683
}
682
684
}
683
685
}
@@ -697,13 +699,13 @@ namespace ts.formatting {
697
699
// without this check close paren will be interpreted as list end token for function expression which is wrong
698
700
if ( tokenInfo . token . kind === listEndToken && rangeContainsRange ( parent , tokenInfo . token ) ) {
699
701
// consume list end token
700
- consumeTokenAndAdvanceScanner ( tokenInfo , parent , listDynamicIndentation ) ;
702
+ consumeTokenAndAdvanceScanner ( tokenInfo , parent , listDynamicIndentation , parent ) ;
701
703
}
702
704
}
703
705
}
704
706
}
705
707
706
- function consumeTokenAndAdvanceScanner ( currentTokenInfo : TokenInfo , parent : Node , dynamicIndentation : DynamicIndentation , container ? : Node ) : void {
708
+ function consumeTokenAndAdvanceScanner ( currentTokenInfo : TokenInfo , parent : Node , dynamicIndentation : DynamicIndentation , container : Node ) : void {
707
709
Debug . assert ( rangeContainsRange ( parent , currentTokenInfo . token ) ) ;
708
710
709
711
const lastTriviaWasNewLine = formattingScanner . lastTrailingTriviaWasNewLine ( ) ;
0 commit comments