File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -597,7 +597,11 @@ module ts.formatting {
597597 if ( listEndToken !== SyntaxKind . Unknown ) {
598598 if ( formattingScanner . isOnToken ( ) ) {
599599 var tokenInfo = formattingScanner . readTokenInfo ( parent ) ;
600- if ( tokenInfo . token . kind === listEndToken ) {
600+ // consume the list end token only if it is still belong to the parent
601+ // there might be the case when current token matches end token but does not considered as one
602+ // function (x: function) <--
603+ // without this check close paren will be interpreted as list end token for function expression which is wrong
604+ if ( tokenInfo . token . kind === listEndToken && rangeContainsRange ( parent , tokenInfo . token ) ) {
601605 // consume list end token
602606 consumeTokenAndAdvanceScanner ( tokenInfo , parent , listDynamicIndentation ) ;
603607 }
Original file line number Diff line number Diff line change 1+ /// <reference path='fourslash.ts' />
2+ ////function f( f: function){/*1*/
3+ goTo . marker ( "1" ) ;
4+ edit . insert ( "}" ) ;
5+ verify . currentLineContentIs ( "function f(f: function){ }" )
You can’t perform that action at this time.
0 commit comments