Skip to content

Commit 825d8bb

Browse files
authored
Merge pull request #32791 from microsoft/documentHighlightsFilesToSearch
Ignore unknown files to search from in document highlights
2 parents 816e7b0 + b7e49d1 commit 825d8bb

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/services/services.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@ namespace ts {
15651565
const normalizedFileName = normalizePath(fileName);
15661566
Debug.assert(filesToSearch.some(f => normalizePath(f) === normalizedFileName));
15671567
synchronizeHostData();
1568-
const sourceFilesToSearch = filesToSearch.map(getValidSourceFile);
1568+
const sourceFilesToSearch = mapDefined(filesToSearch, fileName => program.getSourceFile(fileName));
15691569
const sourceFile = getValidSourceFile(fileName);
15701570
return DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch);
15711571
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @Filename: /node_modules/@types/foo/index.d.ts
4+
////export const x: number;
5+
6+
// @Filename: /a.ts
7+
////import * as foo from "foo";
8+
////foo.[|x|];
9+
10+
// @Filename: /b.ts
11+
////import { [|x|] } from "foo";
12+
13+
// @Filename: /c.ts
14+
////import { x } from "foo";
15+
16+
const [r0, r1] = test.ranges();
17+
verify.rangesAreDocumentHighlights(test.ranges(), { filesToSearch: ["/a.ts", "/b.ts", "/unknown.ts"] });

0 commit comments

Comments
 (0)