Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing RunspaceName #951

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class AttachRequestArguments

public string RunspaceId { get; set; }

public string RunspaceName { get; set; }

public string CustomPipeName { get; set; }
}
}
31 changes: 22 additions & 9 deletions src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,22 +470,35 @@ await requestContext.SendErrorAsync(
// InitializedEvent will be sent as soon as the RunspaceChanged
// event gets fired with the attached runspace.

var runspaceId = 1;
if (!int.TryParse(attachParams.RunspaceId, out runspaceId) || runspaceId <= 0)
string debugRunspaceCmd;
if(attachParams.RunspaceName != null)
TylerLeonhardt marked this conversation as resolved.
Show resolved Hide resolved
{
Logger.Write(
LogLevel.Error,
$"Attach request failed, '{attachParams.RunspaceId}' is an invalid value for the processId.");
debugRunspaceCmd = $"\nDebug-Runspace -Name '{attachParams.RunspaceName}'";
}
else if(attachParams.RunspaceId != null)
TylerLeonhardt marked this conversation as resolved.
Show resolved Hide resolved
{
if (!int.TryParse(attachParams.RunspaceId, out int runspaceId) || runspaceId <= 0)
{
Logger.Write(
LogLevel.Error,
$"Attach request failed, '{attachParams.RunspaceId}' is an invalid value for the processId.");

await requestContext.SendErrorAsync(
"A positive integer must be specified for the RunspaceId field.");
await requestContext.SendErrorAsync(
"A positive integer must be specified for the RunspaceId field.");

return;
return;
}

debugRunspaceCmd = $"\nDebug-Runspace -Id {runspaceId}";
}
else
{
debugRunspaceCmd = "\nDebug-Runspace -Id 1";
}

_waitingForAttach = true;
Task nonAwaitedTask = _editorSession.PowerShellContext
.ExecuteScriptStringAsync($"\nDebug-Runspace -Id {runspaceId}")
.ExecuteScriptStringAsync(debugRunspaceCmd)
.ContinueWith(OnExecutionCompletedAsync);

await requestContext.SendResultAsync(null);
Expand Down