diff --git a/src/PowerShellEditorServices.Host/CodeLens/ReferencesCodeLensProvider.cs b/src/PowerShellEditorServices.Host/CodeLens/ReferencesCodeLensProvider.cs index bed4559a2..abe29a997 100644 --- a/src/PowerShellEditorServices.Host/CodeLens/ReferencesCodeLensProvider.cs +++ b/src/PowerShellEditorServices.Host/CodeLens/ReferencesCodeLensProvider.cs @@ -109,9 +109,9 @@ private static string GetFileUri(string filePath) { // If the file isn't untitled, return a URI-style path return - !filePath.StartsWith("untitled") + !filePath.StartsWith("untitled") && !filePath.StartsWith("inmemory") ? new Uri("file://" + filePath).AbsoluteUri : filePath; } } -} \ No newline at end of file +} diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 31fc68a4f..684d86d7c 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -1358,7 +1358,7 @@ public static string GetFileUri(string filePath) { // If the file isn't untitled, return a URI-style path return - !filePath.StartsWith("untitled") + !filePath.StartsWith("untitled") && !filePath.StartsWith("inmemory") ? new Uri("file://" + filePath).AbsoluteUri : filePath; } diff --git a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs index 272cc891b..d40e59511 100644 --- a/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs +++ b/test/PowerShellEditorServices.Test/Session/WorkspaceTests.cs @@ -57,6 +57,7 @@ public void CanDetermineIsPathInMemory() // Test short non-file paths new { IsInMemory = true, Path = "untitled:untitled-1" }, new { IsInMemory = true, Path = shortUriForm }, + new { IsInMemory = true, Path = "inmemory://foo.ps1" }, // Test long non-file path - known to have crashed PSES new { IsInMemory = true, Path = longUriForm },