Skip to content

Commit f61b67f

Browse files
committed
This fixes the conditional breakpoint moving around issue by removing some breakpoint setting "optimization" code that unfortunately, messes up the order the breakpoint info returned to VSCode.
1 parent f8ed477 commit f61b67f

File tree

1 file changed

+2
-55
lines changed

1 file changed

+2
-55
lines changed

src/PowerShellEditorServices/Debugging/DebugService.cs

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -83,34 +83,7 @@ public async Task<BreakpointDetails[]> SetLineBreakpoints(
8383
string escapedScriptPath =
8484
PowerShellContext.EscapePath(scriptFile.FilePath, escapeSpaces: false);
8585

86-
// Line breakpoints with no condition and no column number are the most common,
87-
// so let's optimize for that case by making a single call to Set-PSBreakpoint
88-
// with all the lines to set a breakpoint on.
89-
int[] lineOnlyBreakpoints =
90-
breakpoints.Where(b => (b.ColumnNumber == null) && (b.Condition == null))
91-
.Select(b => b.LineNumber)
92-
.ToArray();
93-
94-
if (lineOnlyBreakpoints.Length > 0)
95-
{
96-
PSCommand psCommand = new PSCommand();
97-
psCommand.AddCommand("Set-PSBreakpoint");
98-
psCommand.AddParameter("Script", escapedScriptPath);
99-
psCommand.AddParameter("Line", lineOnlyBreakpoints);
100-
101-
var configuredBreakpoints =
102-
await this.powerShellContext.ExecuteCommand<Breakpoint>(psCommand);
103-
104-
resultBreakpointDetails.AddRange(
105-
configuredBreakpoints.Select(BreakpointDetails.Create));
106-
}
107-
108-
// Process the rest of the breakpoints
109-
var advancedLineBreakpoints =
110-
breakpoints.Where(b => (b.ColumnNumber != null) || (b.Condition != null))
111-
.ToArray();
112-
113-
foreach (BreakpointDetails breakpoint in advancedLineBreakpoints)
86+
foreach (BreakpointDetails breakpoint in breakpoints)
11487
{
11588
PSCommand psCommand = new PSCommand();
11689
psCommand.AddCommand("Set-PSBreakpoint");
@@ -174,33 +147,7 @@ public async Task<FunctionBreakpointDetails[]> SetFunctionBreakpoints(
174147

175148
if (breakpoints.Length > 0)
176149
{
177-
// Line function breakpoints with no condition are the most common,
178-
// so let's optimize for that case by making a single call to Set-PSBreakpoint
179-
// with all the command names to set a breakpoint on.
180-
string[] commandOnlyBreakpoints =
181-
breakpoints.Where(b => (b.Condition == null))
182-
.Select(b => b.Name)
183-
.ToArray();
184-
185-
if (commandOnlyBreakpoints.Length > 0)
186-
{
187-
PSCommand psCommand = new PSCommand();
188-
psCommand.AddCommand(@"Microsoft.PowerShell.Utility\Set-PSBreakpoint");
189-
psCommand.AddParameter("Command", commandOnlyBreakpoints);
190-
191-
var configuredBreakpoints =
192-
await this.powerShellContext.ExecuteCommand<Breakpoint>(psCommand);
193-
194-
resultBreakpointDetails.AddRange(
195-
configuredBreakpoints.Select(FunctionBreakpointDetails.Create));
196-
}
197-
198-
// Process the rest of the breakpoints
199-
var advancedCommandBreakpoints =
200-
breakpoints.Where(b => (b.Condition != null))
201-
.ToArray();
202-
203-
foreach (FunctionBreakpointDetails breakpoint in advancedCommandBreakpoints)
150+
foreach (FunctionBreakpointDetails breakpoint in breakpoints)
204151
{
205152
PSCommand psCommand = new PSCommand();
206153
psCommand.AddCommand(@"Microsoft.PowerShell.Utility\Set-PSBreakpoint");

0 commit comments

Comments
 (0)