Skip to content

Commit 0971212

Browse files
authored
Merge pull request microsoft#11284 from Microsoft/vladima/case-sensitivity-services
replace hardcodes 'useCaseSensitiveFileNames=false' in services with actual value, use specialized map lookup methods instead of generic 'getOrCreate*'
2 parents 631ab0a + 8177bd4 commit 0971212

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

src/harness/unittests/tsserverProjectSystem.ts

+18
Original file line numberDiff line numberDiff line change
@@ -2045,4 +2045,22 @@ namespace ts.projectSystem {
20452045
assert.equal(snap.getLength(), expectedLength, "Incorrect snapshot size");
20462046
}
20472047
});
2048+
2049+
describe("Language service", () => {
2050+
it("should work correctly on case-sensitive file systems", () => {
2051+
const lib = {
2052+
path: "/a/Lib/lib.d.ts",
2053+
content: "let x: number"
2054+
};
2055+
const f = {
2056+
path: "/a/b/app.ts",
2057+
content: "let x = 1;"
2058+
};
2059+
const host = createServerHost([lib, f], { executingFilePath: "/a/Lib/tsc.js", useCaseSensitiveFileNames: true });
2060+
const projectService = createProjectService(host);
2061+
projectService.openClientFile(f.path);
2062+
projectService.checkNumberOfProjects({ inferredProjects: 1 });
2063+
projectService.inferredProjects[0].getLanguageService().getProgram();
2064+
});
2065+
});
20482066
}

src/server/editorServices.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,14 @@ namespace ts.server {
10011001
}
10021002

10031003
getScriptInfoForNormalizedPath(fileName: NormalizedPath) {
1004-
return this.filenameToScriptInfo.get(normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName));
1004+
return this.getScriptInfoForPath(normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName));
10051005
}
10061006

1007+
getScriptInfoForPath(fileName: Path) {
1008+
return this.filenameToScriptInfo.get(fileName);
1009+
}
1010+
1011+
10071012
setHostConfiguration(args: protocol.ConfigureRequestArguments) {
10081013
if (args.file) {
10091014
const info = this.getScriptInfoForNormalizedPath(toNormalizedPath(args.file));

src/server/project.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,13 @@ namespace ts.server {
215215
}
216216

217217
getScriptInfos() {
218-
return map(this.program.getSourceFiles(), sourceFile => this.getScriptInfoLSHost(sourceFile.path));
218+
return map(this.program.getSourceFiles(), sourceFile => {
219+
const scriptInfo = this.projectService.getScriptInfoForPath(sourceFile.path);
220+
if (!scriptInfo) {
221+
Debug.assert(false, `scriptInfo for a file '${sourceFile.fileName}' is missing.`);
222+
}
223+
return scriptInfo;
224+
});
219225
}
220226

221227
getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean) {

src/services/services.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ namespace ts {
947947

948948
let lastTypesRootVersion = 0;
949949

950-
const useCaseSensitivefileNames = false;
950+
const useCaseSensitivefileNames = host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames();
951951
const cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
952952

953953
const currentDirectory = host.getCurrentDirectory();

0 commit comments

Comments
 (0)