@@ -120,9 +120,7 @@ public ScriptFile GetFile(DocumentUri documentUri)
120
120
{
121
121
Validate . IsNotNull ( nameof ( documentUri ) , documentUri ) ;
122
122
123
- string keyName = VersionUtils . IsLinux
124
- ? documentUri . ToString ( )
125
- : documentUri . ToString ( ) . ToLower ( ) ;
123
+ string keyName = GetFileKey ( documentUri ) ;
126
124
127
125
// Make sure the file isn't already loaded into the workspace
128
126
if ( ! workspaceFiles . TryGetValue ( keyName , out ScriptFile scriptFile ) )
@@ -258,9 +256,7 @@ public ScriptFile GetFileBuffer(DocumentUri documentUri, string initialBuffer)
258
256
{
259
257
Validate . IsNotNull ( nameof ( documentUri ) , documentUri ) ;
260
258
261
- string keyName = VersionUtils . IsLinux
262
- ? documentUri . ToString ( )
263
- : documentUri . ToString ( ) . ToLower ( ) ;
259
+ string keyName = GetFileKey ( documentUri ) ;
264
260
265
261
// Make sure the file isn't already loaded into the workspace
266
262
if ( ! workspaceFiles . TryGetValue ( keyName , out ScriptFile scriptFile ) && initialBuffer != null )
@@ -293,7 +289,8 @@ public void CloseFile(ScriptFile scriptFile)
293
289
{
294
290
Validate . IsNotNull ( nameof ( scriptFile ) , scriptFile ) ;
295
291
296
- workspaceFiles . TryRemove ( scriptFile . Id , out ScriptFile _ ) ;
292
+ string keyName = GetFileKey ( scriptFile . DocumentUri ) ;
293
+ workspaceFiles . TryRemove ( keyName , out ScriptFile _ ) ;
297
294
}
298
295
299
296
/// <summary>
@@ -540,6 +537,14 @@ internal string ResolveRelativeScriptPath(string baseFilePath, string relativePa
540
537
return combinedPath ;
541
538
}
542
539
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
+
543
548
#endregion
544
549
}
545
550
}
0 commit comments