Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,29 @@ protected Task LaunchScript(RequestContext<object> requestContext)
// Ensure the read loop is stopped
this.editorSession.ConsoleService.CancelReadLoop();

return editorSession.PowerShellContext
.ExecuteScriptWithArgs(this.scriptToLaunch, this.arguments, writeInputToHost: true)
.ContinueWith(this.OnExecutionCompleted);
// Is this an untitled script?
Task launchTask = null;

if (this.scriptToLaunch.StartsWith("untitled"))
{
ScriptFile untitledScript =
this.editorSession.Workspace.GetFile(
this.scriptToLaunch);

launchTask =
this.editorSession
.PowerShellContext
.ExecuteScriptString(untitledScript.Contents, true, true);
}
else
{
launchTask =
this.editorSession
.PowerShellContext
.ExecuteScriptWithArgs(this.scriptToLaunch, this.arguments, writeInputToHost: true);
}

return launchTask.ContinueWith(this.OnExecutionCompleted);
}

private async Task OnExecutionCompleted(Task executeTask)
Expand Down