@@ -135,7 +135,7 @@ namespace ts.server {
135135 /**
136136 * Container of all known scripts
137137 */
138- private readonly filenameToScriptInfo = createNormalizedPathMap < ScriptInfo > ( ) ;
138+ private readonly filenameToScriptInfo = createFileMap < ScriptInfo > ( ) ;
139139 /**
140140 * maps external project file name to list of config files that were the part of this project
141141 */
@@ -165,12 +165,15 @@ namespace ts.server {
165165
166166 private changedFiles : ScriptInfo [ ] ;
167167
168+ private toCanonicalFileName : ( f : string ) => string ;
169+
168170 constructor ( public readonly host : ServerHost ,
169171 public readonly logger : Logger ,
170172 public readonly cancellationToken : HostCancellationToken ,
171173 private readonly useSingleInferredProject : boolean ,
172174 private readonly eventHandler ?: ProjectServiceEventHandler ) {
173175
176+ this . toCanonicalFileName = createGetCanonicalFileName ( host . useCaseSensitiveFileNames ) ;
174177 this . directoryWatchers = new DirectoryWatchers ( this ) ;
175178 this . throttledOperations = new ThrottledOperations ( host ) ;
176179 // ts.disableIncrementalParsing = true;
@@ -300,7 +303,7 @@ namespace ts.server {
300303 // TODO: handle isOpen = true case
301304
302305 if ( ! info . isOpen ) {
303- this . filenameToScriptInfo . remove ( info . fileName ) ;
306+ this . filenameToScriptInfo . remove ( info . path ) ;
304307
305308 // capture list of projects since detachAllProjects will wipe out original list
306309 const containingProjects = info . containingProjects . slice ( ) ;
@@ -504,7 +507,7 @@ namespace ts.server {
504507 }
505508 if ( info . containingProjects . length === 0 ) {
506509 // if there are not projects that include this script info - delete it
507- this . filenameToScriptInfo . remove ( info . fileName ) ;
510+ this . filenameToScriptInfo . remove ( info . path ) ;
508511 }
509512 }
510513
@@ -878,9 +881,9 @@ namespace ts.server {
878881 if ( content !== undefined ) {
879882 info = new ScriptInfo ( this . host , fileName , content , scriptKind , openedByClient , hasMixedContent ) ;
880883 info . setFormatOptions ( toEditorSettings ( this . getFormatCodeOptions ( ) ) ) ;
881- this . filenameToScriptInfo . set ( fileName , info ) ;
884+ // do not watch files with mixed content - server doesn't know how to interpret it
885+ this . filenameToScriptInfo . set ( info . path , info ) ;
882886 if ( ! info . isOpen && ! hasMixedContent ) {
883- // do not watch files with mixed content - server doesn't know how to interpret it
884887 info . setWatcher ( this . host . watchFile ( fileName , _ => this . onSourceFileChanged ( fileName ) ) ) ;
885888 }
886889 }
@@ -897,7 +900,7 @@ namespace ts.server {
897900 }
898901
899902 getScriptInfoForNormalizedPath ( fileName : NormalizedPath ) {
900- return this . filenameToScriptInfo . get ( fileName ) ;
903+ return this . filenameToScriptInfo . get ( normalizedPathToPath ( fileName , this . host . getCurrentDirectory ( ) , this . toCanonicalFileName ) ) ;
901904 }
902905
903906 setHostConfiguration ( args : protocol . ConfigureRequestArguments ) {
@@ -1057,7 +1060,6 @@ namespace ts.server {
10571060 this . closeClientFile ( file ) ;
10581061 }
10591062 }
1060-
10611063 // if files were open or closed then explicitly refresh list of inferred projects
10621064 // otherwise if there were only changes in files - record changed files in `changedFiles` and defer the update
10631065 if ( openFiles || closedFiles ) {
0 commit comments