@@ -717,7 +717,6 @@ namespace ts.formatting {
717
717
Debug . assert ( isNodeArray ( nodes ) ) ;
718
718
719
719
const listStartToken = getOpenTokenForList ( parent , nodes ) ;
720
- const listEndToken = getCloseTokenForOpenToken ( listStartToken ) ;
721
720
722
721
let listDynamicIndentation = parentDynamicIndentation ;
723
722
let startLine = parentStartLine ;
@@ -752,17 +751,21 @@ namespace ts.formatting {
752
751
inheritedIndentation = processChildNode ( child , inheritedIndentation , node , listDynamicIndentation , startLine , startLine , /*isListItem*/ true , /*isFirstListItem*/ i === 0 ) ;
753
752
}
754
753
755
- if ( listEndToken !== SyntaxKind . Unknown ) {
756
- if ( formattingScanner . isOnToken ( ) ) {
757
- const tokenInfo = formattingScanner . readTokenInfo ( parent ) ;
758
- // consume the list end token only if it is still belong to the parent
759
- // there might be the case when current token matches end token but does not considered as one
760
- // function (x: function) <--
761
- // without this check close paren will be interpreted as list end token for function expression which is wrong
762
- if ( tokenInfo . token . kind === listEndToken && rangeContainsRange ( parent , tokenInfo . token ) ) {
763
- // consume list end token
764
- consumeTokenAndAdvanceScanner ( tokenInfo , parent , listDynamicIndentation , parent ) ;
765
- }
754
+ const listEndToken = getCloseTokenForOpenToken ( listStartToken ) ;
755
+ if ( listEndToken !== SyntaxKind . Unknown && formattingScanner . isOnToken ( ) ) {
756
+ let tokenInfo = formattingScanner . readTokenInfo ( parent ) ;
757
+ if ( tokenInfo . token . kind === SyntaxKind . CommaToken && isCallLikeExpression ( parent ) ) {
758
+ formattingScanner . advance ( ) ;
759
+ tokenInfo = formattingScanner . readTokenInfo ( parent ) ;
760
+ }
761
+
762
+ // consume the list end token only if it is still belong to the parent
763
+ // there might be the case when current token matches end token but does not considered as one
764
+ // function (x: function) <--
765
+ // without this check close paren will be interpreted as list end token for function expression which is wrong
766
+ if ( tokenInfo . token . kind === listEndToken && rangeContainsRange ( parent , tokenInfo . token ) ) {
767
+ // consume list end token
768
+ consumeTokenAndAdvanceScanner ( tokenInfo , parent , listDynamicIndentation , parent ) ;
766
769
}
767
770
}
768
771
}
0 commit comments