diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs index b1bc42142..2cfc24a2d 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs @@ -105,9 +105,13 @@ public Task Handle(ConfigurationDoneArguments request private async Task LaunchScriptAsync(string scriptToLaunch) { PSCommand command; - // Script could an actual script, or a URI to a script file (or untitled document). - if (!System.Uri.IsWellFormedUriString(scriptToLaunch, System.UriKind.RelativeOrAbsolute) - || ScriptFile.IsUntitledPath(scriptToLaunch)) + if (System.IO.File.Exists(scriptToLaunch)) + { + // For a saved file we just execute its path (after escaping it). + command = PSCommandHelpers.BuildDotSourceCommandWithArguments( + string.Concat('"', scriptToLaunch, '"'), _debugStateService.Arguments); + } + else // It's a URI to an untitled script, or a raw script. { bool isScriptFile = _workspaceService.TryGetFile(scriptToLaunch, out ScriptFile untitledScript); if (isScriptFile && BreakpointApiUtils.SupportsBreakpointApis(_runspaceContext.CurrentRunspace)) @@ -147,12 +151,6 @@ private async Task LaunchScriptAsync(string scriptToLaunch) _debugStateService.Arguments); } } - else - { - // For a saved file we just execute its path (after escaping it). - command = PSCommandHelpers.BuildDotSourceCommandWithArguments( - string.Concat('"', scriptToLaunch, '"'), _debugStateService.Arguments); - } await _executionService.ExecutePSCommandAsync( command,