This commit is contained in:
uniqueiniquity 2018-04-16 15:58:39 -07:00
parent 003c0a6743
commit e9d6f788ca
3 changed files with 14 additions and 2 deletions

View File

@ -2910,6 +2910,11 @@ Actual: ${stringify(fullActual)}`);
}
private verifyDocumentHighlights(expectedRanges: Range[], fileNames: ReadonlyArray<string> = [this.activeFile.fileName]) {
expectedRanges = ts.map(expectedRanges, r => {
r.fileName = ts.normalizePath(r.fileName);
return r;
});
fileNames = ts.map(fileNames, ts.normalizePath);
const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNames) || [];
for (const dh of documentHighlights) {
@ -3219,7 +3224,7 @@ Actual: ${stringify(fullActual)}`);
}
}
else if (ts.isString(indexOrName)) {
let name = indexOrName;
let name = ts.normalizePath(indexOrName);
// names are stored in the compiler with this relative path, this allows people to use goTo.file on just the fileName
name = name.indexOf("/") === -1 ? (this.basePath + "/" + name) : name;

View File

@ -125,7 +125,7 @@ namespace Utils {
addFile(path: string, content?: Harness.LanguageService.ScriptInfo) {
const absolutePath = ts.normalizePath(ts.getNormalizedAbsolutePath(path, this.currentDirectory));
const fileName = ts.getBaseFileName(path);
const fileName = ts.getBaseFileName(absolutePath);
const directoryPath = ts.getDirectoryPath(absolutePath);
const directory = this.addDirectory(directoryPath);
return directory ? directory.addFile(fileName, content) : undefined;

View File

@ -0,0 +1,7 @@
/// <reference path='fourslash.ts' />
//@Filename: C:\a\b\c.ts
////var /*1*/[|x|] = 1;
const range = test.ranges()[0];
verify.documentHighlightsOf(range, [range], { filesToSearch: [range.fileName] });