@@ -120,9 +120,7 @@ public ScriptFile GetFile(DocumentUri documentUri)
120120 {
121121 Validate . IsNotNull ( nameof ( documentUri ) , documentUri ) ;
122122
123- string keyName = VersionUtils . IsLinux
124- ? documentUri . ToString ( )
125- : documentUri . ToString ( ) . ToLower ( ) ;
123+ string keyName = GetFileKey ( documentUri ) ;
126124
127125 // Make sure the file isn't already loaded into the workspace
128126 if ( ! workspaceFiles . TryGetValue ( keyName , out ScriptFile scriptFile ) )
@@ -258,9 +256,7 @@ public ScriptFile GetFileBuffer(DocumentUri documentUri, string initialBuffer)
258256 {
259257 Validate . IsNotNull ( nameof ( documentUri ) , documentUri ) ;
260258
261- string keyName = VersionUtils . IsLinux
262- ? documentUri . ToString ( )
263- : documentUri . ToString ( ) . ToLower ( ) ;
259+ string keyName = GetFileKey ( documentUri ) ;
264260
265261 // Make sure the file isn't already loaded into the workspace
266262 if ( ! workspaceFiles . TryGetValue ( keyName , out ScriptFile scriptFile ) && initialBuffer != null )
@@ -293,7 +289,8 @@ public void CloseFile(ScriptFile scriptFile)
293289 {
294290 Validate . IsNotNull ( nameof ( scriptFile ) , scriptFile ) ;
295291
296- workspaceFiles . TryRemove ( scriptFile . Id , out ScriptFile _ ) ;
292+ string keyName = GetFileKey ( scriptFile . DocumentUri ) ;
293+ workspaceFiles . TryRemove ( keyName , out ScriptFile _ ) ;
297294 }
298295
299296 /// <summary>
@@ -540,6 +537,14 @@ internal string ResolveRelativeScriptPath(string baseFilePath, string relativePa
540537 return combinedPath ;
541538 }
542539
540+ /// <summary>
541+ /// Returns a normalized string for a given documentUri to be used as key name.
542+ /// Case-sensitive uri on Linux and lowercase for other platforms.
543+ /// </summary>
544+ /// <param name="documentUri">A DocumentUri object to get a normalized key name from</param>
545+ private static string GetFileKey ( DocumentUri documentUri )
546+ => VersionUtils . IsLinux ? documentUri . ToString ( ) : documentUri . ToString ( ) . ToLower ( ) ;
547+
543548 #endregion
544549 }
545550}
0 commit comments