Skip to content

Commit a9a994c

Browse files
committed
Merge pull request microsoft#1658 from Microsoft/emptyParamList
when formatting lists check if end list token still belongs to the paren...
2 parents cbecae3 + 150720b commit a9a994c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/services/formatting/formatting.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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){ }")

0 commit comments

Comments
 (0)