Skip to content

Commit 5108285

Browse files
committed
Port (#12474)
1 parent c43c37f commit 5108285

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

‎src/harness/unittests/tsserverProjectSystem.ts‎

Lines 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+
constf1={
583+
path: "/a/b/app.ts",
584+
content: "let x = 1"
585+
};
586+
constconfig={
587+
path: "/a/b/tsconfig.json",
588+
content: JSON.stringify({
589+
include: []
590+
})
591+
};
592+
593+
consthost=createServerHost([f1,config],{useCaseSensitiveFileNames: false});
594+
constservice=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
constconfigFile: FileOrFolder={
583612
path: "/a/b/tsconfig.json",

‎src/server/editorServices.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ namespace ts.server{
257257

258258
privatechangedFiles: ScriptInfo[];
259259

260-
privatetoCanonicalFileName: (f: string)=>string;
260+
readonlytoCanonicalFileName: (f: string)=>string;
261261

262262
publiclastDeletedFile: ScriptInfo;
263263

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

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

783789
privatefindExternalProjectByProjectName(projectFileName: string){

‎src/server/project.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ namespace ts.server{
817817
privatedirectoryWatcher: FileWatcher;
818818
privatedirectoriesWatchedForWildcards: Map<FileWatcher>;
819819
privatetypeRootsWatchers: FileWatcher[];
820+
readonlycanonicalConfigFilePath: 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
publiccompileOnSaveEnabled: 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)