@@ -105,10 +105,12 @@ public Task<ConfigurationDoneResponse> Handle(ConfigurationDoneArguments request
105
105
private async Task LaunchScriptAsync ( string scriptToLaunch )
106
106
{
107
107
PSCommand command ;
108
- if ( ScriptFile . IsUntitledPath ( scriptToLaunch ) )
108
+ // Script could an actual script, or a URI to a script file (or untitled document).
109
+ if ( ! System . Uri . IsWellFormedUriString ( scriptToLaunch , System . UriKind . RelativeOrAbsolute )
110
+ || ScriptFile . IsUntitledPath ( scriptToLaunch ) )
109
111
{
110
- ScriptFile untitledScript = _workspaceService . GetFile ( scriptToLaunch ) ;
111
- if ( BreakpointApiUtils . SupportsBreakpointApis ( _runspaceContext . CurrentRunspace ) )
112
+ bool isScriptFile = _workspaceService . TryGetFile ( scriptToLaunch , out ScriptFile untitledScript ) ;
113
+ if ( isScriptFile && BreakpointApiUtils . SupportsBreakpointApis ( _runspaceContext . CurrentRunspace ) )
112
114
{
113
115
// Parse untitled files with their `Untitled:` URI as the filename which will
114
116
// cache the URI and contents within the PowerShell parser. By doing this, we
@@ -138,7 +140,11 @@ private async Task LaunchScriptAsync(string scriptToLaunch)
138
140
// Command breakpoints and `Wait-Debugger` will work. We must wrap the script
139
141
// with newlines so that any included comments don't break the command.
140
142
command = PSCommandHelpers . BuildDotSourceCommandWithArguments (
141
- string . Concat ( "{\n " , untitledScript . Contents , "\n }" ) , _debugStateService . Arguments ) ;
143
+ string . Concat (
144
+ "{" + System . Environment . NewLine ,
145
+ isScriptFile ? untitledScript . Contents : scriptToLaunch ,
146
+ System . Environment . NewLine + "}" ) ,
147
+ _debugStateService . Arguments ) ;
142
148
}
143
149
}
144
150
else
0 commit comments