Update error case check

`getTouchingWord` indicates failure by returning the sourceFile node,
rather than `undefined`.
This commit is contained in:
Andrew Casey
2017-06-29 10:39:30 -07:00
parent 977525b37e
commit 587309d029
+4 -1
View File
@@ -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.