Skip to content

Commit 587309d

Browse files
committed
Update error case check
`getTouchingWord` indicates failure by returning the sourceFile node, rather than `undefined`.
1 parent 977525b commit 587309d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/services/documentHighlights.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
namespace ts.DocumentHighlights {
33
export function getDocumentHighlights(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] | undefined {
44
const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true);
5-
if (!node) return undefined;
5+
// Note that getTouchingWord indicates failure by returning the sourceFile node.
6+
if (node === sourceFile) return undefined;
7+
8+
Debug.assert(node.parent !== undefined);
69

710
if (isJsxOpeningElement(node.parent) && node.parent.tagName === node || isJsxClosingElement(node.parent)) {
811
// For a JSX element, just highlight the matching tag, not all references.

0 commit comments

Comments
 (0)