From 98f8ec5d5a3bdf4e59bf87686125f14519314657 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Tue, 7 Oct 2014 15:36:55 -0700 Subject: [PATCH] Fix crash when getting member completion for an object literal --- src/services/services.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index e4d28f4700f..b4522849e2a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2144,9 +2144,16 @@ module ts { } // TODO: this is a hack for now, we need a proper walking mechanism to verify that we have the correct node - var mappedNode = getTouchingToken(sourceFile, TypeScript.end(node) - 1); - if (isPunctuation(mappedNode.kind)) { - mappedNode = mappedNode.parent; + var precedingToken = findTokenOnLeftOfPosition(sourceFile, TypeScript.end(node)); + var mappedNode: Node; + if (!precedingToken) { + mappedNode = sourceFile; + } + else if (isPunctuation(precedingToken.kind)) { + mappedNode = precedingToken.parent; + } + else { + mappedNode = precedingToken; } Debug.assert(mappedNode, "Could not map a Fidelity node to an AST node");