when formatting lists check if end list token still belongs to the parent node

This commit is contained in:
Vladimir Matveev 2015-01-13 14:22:53 -08:00
parent cbecae3cf3
commit 150720bd70
2 changed files with 10 additions and 1 deletions

View File

@ -597,7 +597,11 @@ module ts.formatting {
if (listEndToken !== SyntaxKind.Unknown) {
if (formattingScanner.isOnToken()) {
var tokenInfo = formattingScanner.readTokenInfo(parent);
if (tokenInfo.token.kind === listEndToken) {
// consume the list end token only if it is still belong to the parent
// there might be the case when current token matches end token but does not considered as one
// function (x: function) <--
// without this check close paren will be interpreted as list end token for function expression which is wrong
if (tokenInfo.token.kind === listEndToken && rangeContainsRange(parent, tokenInfo.token)) {
// consume list end token
consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation);
}

View File

@ -0,0 +1,5 @@
/// <reference path='fourslash.ts' />
////function f( f: function){/*1*/
goTo.marker("1");
edit.insert("}");
verify.currentLineContentIs("function f(f: function){ }")