From 686a10085c55d3ab77ecacf2200596103629b540 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 16 Mar 2015 23:05:03 -0700 Subject: [PATCH] Moved construct signature down appropriately, fixed logic for function-like constructs. --- src/services/formatting/smartIndenter.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 36e3f8579df..76a95bcdadc 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -446,7 +446,6 @@ module ts.formatting { } // fall through case SyntaxKind.CallExpression: - case SyntaxKind.ConstructSignature: case SyntaxKind.ParenthesizedExpression: case SyntaxKind.ParenthesizedType: return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile); @@ -462,14 +461,20 @@ module ts.formatting { case SyntaxKind.FunctionExpression: case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: + case SyntaxKind.ConstructSignature: case SyntaxKind.CallSignature: case SyntaxKind.ArrowFunction: if ((n).body) { return isCompletedNode((n).body, sourceFile); } - return hasChildOfKind(n, SyntaxKind.CloseParenToken, sourceFile) || - (n).typeParameters && hasChildOfKind(n, SyntaxKind.GreaterThanToken, sourceFile) + if ((n).type) { + return isCompletedNode((n).type, sourceFile); + } + + // Even though type parameters can be unclosed, we can get away with + // having at least a closing paren. + return hasChildOfKind(n, SyntaxKind.CloseParenToken, sourceFile); case SyntaxKind.ModuleDeclaration: return (n).body && isCompletedNode((n).body, sourceFile);