mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 23:08:20 -06:00
when formatting lists check if end list token still belongs to the parent node
This commit is contained in:
parent
cbecae3cf3
commit
150720bd70
@ -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);
|
||||
}
|
||||
|
||||
5
tests/cases/fourslash/formatEmptyParamList.ts
Normal file
5
tests/cases/fourslash/formatEmptyParamList.ts
Normal 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){ }")
|
||||
Loading…
x
Reference in New Issue
Block a user