From 0437dfb594c53ee124eafc794106eaeb44082d58 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 25 Mar 2015 16:37:41 -0700 Subject: [PATCH] Adjust the context token if the previous token is a word, not just if it's an identifier. --- src/services/services.ts | 2 +- src/services/utilities.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 589022872e2..41ffc04e5ae 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2486,7 +2486,7 @@ module ts { // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. - if (contextToken && position <= contextToken.end && contextToken.kind === SyntaxKind.Identifier) { + if (contextToken && position <= contextToken.end && isWord(contextToken.kind)) { let start = new Date().getTime(); contextToken = findPrecedingToken(contextToken.getFullStart(), sourceFile); log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start)); diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 756fbb42597..719aa658724 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -450,7 +450,7 @@ module ts { return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; } - function isWord(kind: SyntaxKind): boolean { + export function isWord(kind: SyntaxKind): boolean { return kind === SyntaxKind.Identifier || isKeyword(kind); }