Skip to content

Run one invocation per SetBreakpoints request #1117

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

Merged
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
24 changes: 20 additions & 4 deletions src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,24 @@ public async Task<BreakpointDetails[]> SetLineBreakpointsAsync(
await this.ClearBreakpointsInFileAsync(scriptFile);
}

PSCommand psCommand = null;
foreach (BreakpointDetails breakpoint in breakpoints)
{
PSCommand psCommand = new PSCommand();
psCommand.AddCommand(@"Microsoft.PowerShell.Utility\Set-PSBreakpoint");
psCommand.AddParameter("Script", escapedScriptPath);
psCommand.AddParameter("Line", breakpoint.LineNumber);
// On first iteration psCommand will be null, every subsequent
// iteration will need to start a new statement.
if (psCommand == null)
{
psCommand = new PSCommand();
}
else
{
psCommand.AddStatement();
}

psCommand
.AddCommand(@"Microsoft.PowerShell.Utility\Set-PSBreakpoint")
.AddParameter("Script", escapedScriptPath)
.AddParameter("Line", breakpoint.LineNumber);

// Check if the user has specified the column number for the breakpoint.
if (breakpoint.ColumnNumber.HasValue && breakpoint.ColumnNumber.Value > 0)
Expand Down Expand Up @@ -222,7 +234,11 @@ public async Task<BreakpointDetails[]> SetLineBreakpointsAsync(

psCommand.AddParameter("Action", actionScriptBlock);
}
}

// If no PSCommand was created then there are no breakpoints to set.
if (psCommand != null)
{
IEnumerable<Breakpoint> configuredBreakpoints =
await this.powerShellContext.ExecuteCommandAsync<Breakpoint>(psCommand);

Expand Down