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
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