Skip to content

Commit 98f8ec5

Browse files
committed
Fix crash when getting member completion for an object literal
1 parent 0625cc4 commit 98f8ec5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/services/services.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,9 +2144,16 @@ module ts {
21442144
}
21452145

21462146
// TODO: this is a hack for now, we need a proper walking mechanism to verify that we have the correct node
2147-
var mappedNode = getTouchingToken(sourceFile, TypeScript.end(node) - 1);
2148-
if (isPunctuation(mappedNode.kind)) {
2149-
mappedNode = mappedNode.parent;
2147+
var precedingToken = findTokenOnLeftOfPosition(sourceFile, TypeScript.end(node));
2148+
var mappedNode: Node;
2149+
if (!precedingToken) {
2150+
mappedNode = sourceFile;
2151+
}
2152+
else if (isPunctuation(precedingToken.kind)) {
2153+
mappedNode = precedingToken.parent;
2154+
}
2155+
else {
2156+
mappedNode = precedingToken;
21502157
}
21512158

21522159
Debug.assert(mappedNode, "Could not map a Fidelity node to an AST node");

0 commit comments

Comments
 (0)