Fix crash when getting member completion for an object literal

This commit is contained in:
Jason Freeman
2014-10-07 15:36:55 -07:00
parent 0625cc4650
commit 98f8ec5d5a

View File

@@ -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");