Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eb804a9

Browse filesBrowse files
committed
getSemanticDocumentHighlights: don't fail...
...when missing `program.redirectTargetsMap` info. This assertion fails in the added test case -- looks like there is no entry in `program.redirectTargetsMap` when it comes from a file that is no in the project. So in this case don't follow the (missing) info, and instead drop the highlight. Fixes microsoft#33722.
1 parent 42b0e3c commit eb804a9
Copy full SHA for eb804a9

2 files changed

+21-2Lines changed: 21 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/services/documentHighlights.ts‎

Copy file name to clipboardExpand all lines: src/services/documentHighlights.ts
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ namespace ts {
3232
const referenceEntries = FindAllReferences.getReferenceEntriesForNode(position, node, program, sourceFilesToSearch, cancellationToken, /*options*/ undefined, sourceFilesSet);
3333
if (!referenceEntries) return undefined;
3434
const map = arrayToMultiMap(referenceEntries.map(FindAllReferences.toHighlightSpan), e => e.fileName, e => e.span);
35-
return arrayFrom(map.entries(), ([fileName, highlightSpans]) => {
35+
return mapDefined(arrayFrom(map.entries()), ([fileName, highlightSpans]) => {
3636
if (!sourceFilesSet.has(fileName)) {
37-
Debug.assert(program.redirectTargetsMap.has(fileName));
37+
if (!program.redirectTargetsMap.has(fileName)) {
38+
return undefined;
39+
}
3840
const redirectTarget = program.getSourceFile(fileName);
3941
const redirect = find(sourceFilesToSearch, f => !!f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget)!;
4042
fileName = redirect.fileName;
Collapse file
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @Filename: /y.ts
4+
////class Foo {
5+
//// private foo() {}
6+
////}
7+
////
8+
////const f = () => new Foo();
9+
////export default f;
10+
11+
// @Filename: /x.ts
12+
////import y from "./y";
13+
////
14+
////y().[|foo|]();
15+
16+
const [r] = test.ranges();
17+
verify.documentHighlightsOf(r, [], { filesToSearch: ["/x.ts"] });

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.