Merge pull request #32791 from microsoft/documentHighlightsFilesToSearch

Ignore unknown files to search from in document highlights
This commit is contained in:
Sheetal Nandi 2019-08-09 15:34:05 -07:00 committed by GitHub
commit 825d8bb1dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -1565,7 +1565,7 @@ namespace ts {
const normalizedFileName = normalizePath(fileName);
Debug.assert(filesToSearch.some(f => normalizePath(f) === normalizedFileName));
synchronizeHostData();
const sourceFilesToSearch = filesToSearch.map(getValidSourceFile);
const sourceFilesToSearch = mapDefined(filesToSearch, fileName => program.getSourceFile(fileName));
const sourceFile = getValidSourceFile(fileName);
return DocumentHighlights.getDocumentHighlights(program, cancellationToken, sourceFile, position, sourceFilesToSearch);
}

View file

@ -0,0 +1,17 @@
/// <reference path="fourslash.ts" />
// @Filename: /node_modules/@types/foo/index.d.ts
////export const x: number;
// @Filename: /a.ts
////import * as foo from "foo";
////foo.[|x|];
// @Filename: /b.ts
////import { [|x|] } from "foo";
// @Filename: /c.ts
////import { x } from "foo";
const [r0, r1] = test.ranges();
verify.rangesAreDocumentHighlights(test.ranges(), { filesToSearch: ["/a.ts", "/b.ts", "/unknown.ts"] });