Skip to content

Commit e9d6f78

Browse files
Add test
1 parent 003c0a6 commit e9d6f78

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/harness/fourslash.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2910,6 +2910,11 @@ Actual: ${stringify(fullActual)}`);
29102910
}
29112911

29122912
private verifyDocumentHighlights(expectedRanges: Range[], fileNames: ReadonlyArray<string> = [this.activeFile.fileName]) {
2913+
expectedRanges = ts.map(expectedRanges, r => {
2914+
r.fileName = ts.normalizePath(r.fileName);
2915+
return r;
2916+
});
2917+
fileNames = ts.map(fileNames, ts.normalizePath);
29132918
const documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNames) || [];
29142919

29152920
for (const dh of documentHighlights) {
@@ -3219,7 +3224,7 @@ Actual: ${stringify(fullActual)}`);
32193224
}
32203225
}
32213226
else if (ts.isString(indexOrName)) {
3222-
let name = indexOrName;
3227+
let name = ts.normalizePath(indexOrName);
32233228

32243229
// names are stored in the compiler with this relative path, this allows people to use goTo.file on just the fileName
32253230
name = name.indexOf("/") === -1 ? (this.basePath + "/" + name) : name;

src/harness/virtualFileSystem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ namespace Utils {
125125

126126
addFile(path: string, content?: Harness.LanguageService.ScriptInfo) {
127127
const absolutePath = ts.normalizePath(ts.getNormalizedAbsolutePath(path, this.currentDirectory));
128-
const fileName = ts.getBaseFileName(path);
128+
const fileName = ts.getBaseFileName(absolutePath);
129129
const directoryPath = ts.getDirectoryPath(absolutePath);
130130
const directory = this.addDirectory(directoryPath);
131131
return directory ? directory.addFile(fileName, content) : undefined;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
//@Filename: C:\a\b\c.ts
4+
////var /*1*/[|x|] = 1;
5+
6+
const range = test.ranges()[0];
7+
verify.documentHighlightsOf(range, [range], { filesToSearch: [range.fileName] });

0 commit comments

Comments
 (0)