Skip to content

Provide a bit more accurate "reason" for debug stop. #179

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
17 changes: 16 additions & 1 deletion src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,21 @@ async void DebugService_DebuggerStopped(object sender, DebuggerStopEventArgs e)
// Flush pending output before sending the event
await this.outputDebouncer.Flush();

// Provide the reason for why the debugger has stopped script execution.
// See https://github.com/Microsoft/vscode/issues/3648
// The reason is displayed in the breakpoints viewlet. Some recommended reasons are:
// "step", "breakpoint", "function breakpoint", "exception" and "pause".
// We don't support exception breakpoints and for "pause", we can't distinguish
// between stepping and the user pressing the pause/break button in the debug toolbar.
string debuggerStoppedReason = "step";
if (e.Breakpoints.Count > 0)
{
debuggerStoppedReason =
e.Breakpoints[0] is CommandBreakpoint
? "function breakpoint"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this style for ternary operators, cleaner than the one I normally use.

: "breakpoint";
}

await this.SendEvent(
StoppedEvent.Type,
new StoppedEventBody
Expand All @@ -485,7 +500,7 @@ await this.SendEvent(
Line = e.InvocationInfo.ScriptLineNumber,
Column = e.InvocationInfo.OffsetInLine,
ThreadId = 1, // TODO: Change this based on context
Reason = "breakpoint" // TODO: Change this based on context
Reason = debuggerStoppedReason
});
}

Expand Down