Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5108285

Browse filesBrowse files
author
zhengbli
committed
Port (#12474)
1 parent c43c37f commit 5108285
Copy full SHA for 5108285

3 files changed

+39-2Lines changed: 39 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/harness/unittests/tsserverProjectSystem.ts‎

Copy file name to clipboardExpand all lines: src/harness/unittests/tsserverProjectSystem.ts
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,35 @@ namespace ts.projectSystem {
578578
checkWatchedDirectories(host, ["/a/b/c", "/a/b", "/a"]);
579579
});
580580

581+
it("can handle tsconfig file name with difference casing", () => {
582+
const f1 = {
583+
path: "/a/b/app.ts",
584+
content: "let x = 1"
585+
};
586+
const config = {
587+
path: "/a/b/tsconfig.json",
588+
content: JSON.stringify({
589+
include: []
590+
})
591+
};
592+
593+
const host = createServerHost([f1, config], { useCaseSensitiveFileNames: false });
594+
const service = createProjectService(host);
595+
service.openExternalProject(<protocol.ExternalProject>{
596+
projectFileName: "/a/b/project.csproj",
597+
rootFiles: toExternalFiles([f1.path, combinePaths(getDirectoryPath(config.path).toUpperCase(), getBaseFileName(config.path))]),
598+
options: {}
599+
});
600+
service.checkNumberOfProjects({ configuredProjects: 1 });
601+
checkProjectActualFiles(service.configuredProjects[0], []);
602+
603+
service.openClientFile(f1.path);
604+
service.checkNumberOfProjects({ configuredProjects: 1, inferredProjects: 1 });
605+
606+
checkProjectActualFiles(service.configuredProjects[0], []);
607+
checkProjectActualFiles(service.inferredProjects[0], [f1.path]);
608+
})
609+
581610
it("create configured project without file list", () => {
582611
const configFile: FileOrFolder = {
583612
path: "/a/b/tsconfig.json",
Collapse file

‎src/server/editorServices.ts‎

Copy file name to clipboardExpand all lines: src/server/editorServices.ts
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ namespace ts.server {
257257

258258
private changedFiles: ScriptInfo[];
259259

260-
private toCanonicalFileName: (f: string) => string;
260+
readonly toCanonicalFileName: (f: string) => string;
261261

262262
public lastDeletedFile: ScriptInfo;
263263

@@ -777,7 +777,13 @@ namespace ts.server {
777777
}
778778

779779
private findConfiguredProjectByProjectName(configFileName: NormalizedPath) {
780-
return findProjectByName(configFileName, this.configuredProjects);
780+
// make sure that casing of config file name is consistent
781+
configFileName = asNormalizedPath(this.toCanonicalFileName(configFileName));
782+
for (const proj of this.configuredProjects) {
783+
if (proj.canonicalConfigFilePath === configFileName) {
784+
return proj;
785+
}
786+
}
781787
}
782788

783789
private findExternalProjectByProjectName(projectFileName: string) {
Collapse file

‎src/server/project.ts‎

Copy file name to clipboardExpand all lines: src/server/project.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ namespace ts.server {
817817
private directoryWatcher: FileWatcher;
818818
private directoriesWatchedForWildcards: Map<FileWatcher>;
819819
private typeRootsWatchers: FileWatcher[];
820+
readonly canonicalConfigFilePath: NormalizedPath;
820821

821822
/** Used for configured projects which may have multiple open roots */
822823
openRefCount = 0;
@@ -830,6 +831,7 @@ namespace ts.server {
830831
languageServiceEnabled: boolean,
831832
public compileOnSaveEnabled: boolean) {
832833
super(configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled);
834+
this.canonicalConfigFilePath = asNormalizedPath(projectService.toCanonicalFileName(configFileName));
833835
}
834836

835837
getConfigFilePath() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.