1919using Microsoft . PowerShell . EditorServices . Test ;
2020using Microsoft . PowerShell . EditorServices . Test . Shared ;
2121using Microsoft . PowerShell . EditorServices . Utility ;
22+ using OmniSharp . Extensions . LanguageServer . Protocol ;
2223using Xunit ;
2324
2425namespace PowerShellEditorServices . Test . Debugging
@@ -42,6 +43,7 @@ public class DebugServiceTests : IDisposable
4243 private readonly WorkspaceService workspace ;
4344 private readonly ScriptFile debugScriptFile ;
4445 private readonly ScriptFile oddPathScriptFile ;
46+ private readonly ScriptFile psProviderPathScriptFile ;
4547 private readonly ScriptFile variableScriptFile ;
4648 private readonly TestReadLine testReadLine = new ( ) ;
4749
@@ -74,6 +76,12 @@ public DebugServiceTests()
7476 debugScriptFile = GetDebugScript ( "DebugTest.ps1" ) ;
7577 oddPathScriptFile = GetDebugScript ( "Debug' W&ith $Params [Test].ps1" ) ;
7678 variableScriptFile = GetDebugScript ( "VariableTest.ps1" ) ;
79+ string variableScriptFilePath = TestUtilities . GetSharedPath ( Path . Combine ( "Debugging" , "VariableTest.ps1" ) ) ;
80+ dynamic psitem = psesHost . ExecutePSCommandAsync < dynamic > ( new PSCommand ( ) . AddCommand ( "Get-Item" ) . AddParameter ( "LiteralPath" , variableScriptFilePath ) , CancellationToken . None ) . GetAwaiter ( ) . GetResult ( ) . FirstOrDefault ( ) ;
81+ Uri fileUri = new Uri ( psitem . FullName ) ;
82+ string pspathUriString = new DocumentUri ( scheme : "pspath" , authority : $ "{ psitem . PSProvider . ToString ( ) . Replace ( "\\ " , "-" ) } ", path : $ "/{ fileUri . AbsolutePath } ", query : string . Empty , fragment : string . Empty ) . ToString ( ) ;
83+ // pspath://microsoft.powershell.core-filesystem/c:/Users/dkattan/source/repos/immybot-ref/submodules/PowerShellEditorServices/test/PowerShellEditorServices.Test.Shared/Debugging/VariableTest.ps1
84+ psProviderPathScriptFile = workspace . GetFile ( pspathUriString ) ;
7785 }
7886
7987 public void Dispose ( )
@@ -621,6 +629,22 @@ public async Task OddFilePathsLaunchCorrectly()
621629 Assert . Equal ( ". " + PSCommandHelpers . EscapeScriptFilePath ( oddPathScriptFile . FilePath ) , Assert . Single ( historyResult ) ) ;
622630 }
623631
632+
633+ [ Fact ]
634+ public async Task PSProviderPathsLaunchCorrectly ( )
635+ {
636+ ConfigurationDoneHandler configurationDoneHandler = new (
637+ NullLoggerFactory . Instance , null , debugService , null , null , psesHost , workspace , null , psesHost ) ;
638+ await configurationDoneHandler . LaunchScriptAsync ( psProviderPathScriptFile . FilePath ) ;
639+
640+ IReadOnlyList < string > historyResult = await psesHost . ExecutePSCommandAsync < string > (
641+ new PSCommand ( ) . AddScript ( "(Get-History).CommandLine" ) ,
642+ CancellationToken . None ) ;
643+
644+ // Check the PowerShell history
645+ Assert . Equal ( ". " + PSCommandHelpers . EscapeScriptFilePath ( oddPathScriptFile . FilePath ) , Assert . Single ( historyResult ) ) ;
646+ }
647+
624648 [ Fact ]
625649 public async Task DebuggerVariableStringDisplaysCorrectly ( )
626650 {
0 commit comments