From 587309d029964d17398bf74de99a49e5451957d3 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Mon, 19 Jun 2017 15:45:47 -0700 Subject: [PATCH] Update error case check `getTouchingWord` indicates failure by returning the sourceFile node, rather than `undefined`. --- src/services/documentHighlights.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 7ea8c519646..fc84b60cc1f 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -2,7 +2,10 @@ namespace ts.DocumentHighlights { export function getDocumentHighlights(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] | undefined { const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); - if (!node) return undefined; + // Note that getTouchingWord indicates failure by returning the sourceFile node. + if (node === sourceFile) return undefined; + + Debug.assert(node.parent !== undefined); if (isJsxOpeningElement(node.parent) && node.parent.tagName === node || isJsxClosingElement(node.parent)) { // For a JSX element, just highlight the matching tag, not all references.