Skip to content

Commit 5b622ce

Browse files
committed
Provide a bit more accurate "reason" for debug stop.
It turns out that when the debugger stops at a function breakpoint, it isn't necessarily obvious why the debugger stopped. There is no breakpoint glyph for a function breakpoint. So if we return "function breakpoint", then VSCode will display "PAUSED ON FUNCTION BREAKPOINT" in the call stack viewlet. Hopefully that will help the user know why the debugger stopped.
1 parent 3bd9a26 commit 5b622ce

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,21 @@ async void DebugService_DebuggerStopped(object sender, DebuggerStopEventArgs e)
474474
// Flush pending output before sending the event
475475
await this.outputDebouncer.Flush();
476476

477+
// Provide the reason for why the debugger has stopped script execution.
478+
// See https://github.com/Microsoft/vscode/issues/3648
479+
// The reason is displayed in the breakpoints viewlet. Some recommended reasons are:
480+
// "step", "breakpoint", "function breakpoint", "exception" and "pause".
481+
// We don't support exception breakpoints and for "pause", we can't distinguish
482+
// between stepping and the user pressing the pause/break button in the debug toolbar.
483+
string debuggerStoppedReason = "step";
484+
if (e.Breakpoints.Count > 0)
485+
{
486+
debuggerStoppedReason =
487+
e.Breakpoints[0] is CommandBreakpoint
488+
? "function breakpoint"
489+
: "breakpoint";
490+
}
491+
477492
await this.SendEvent(
478493
StoppedEvent.Type,
479494
new StoppedEventBody
@@ -485,7 +500,7 @@ await this.SendEvent(
485500
Line = e.InvocationInfo.ScriptLineNumber,
486501
Column = e.InvocationInfo.OffsetInLine,
487502
ThreadId = 1, // TODO: Change this based on context
488-
Reason = "breakpoint" // TODO: Change this based on context
503+
Reason = debuggerStoppedReason
489504
});
490505
}
491506

0 commit comments

Comments
 (0)