Skip to content

Commit 10539ad

Browse files
committed
Add !ctrlc and !break commands to debug adapter evaluator
This change adds the !ctrlc and !break commands which are special to the debug adapter's REPL interface. The provide the ability to send a Ctrl+C (abort) or Ctrl+B (break) at any time. This is necessary because the debugger UI can't properly handle or transfer these commands in some cases.
1 parent 0c25944 commit 10539ad

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,22 @@ protected async Task HandleEvaluateRequest(
638638

639639
if (isFromRepl)
640640
{
641-
// Send the input through the console service
642-
editorSession.ConsoleService.ExecuteCommand(
643-
evaluateParams.Expression,
644-
false);
641+
// Check for special commands
642+
if (string.Equals("!ctrlc", evaluateParams.Expression, StringComparison.CurrentCultureIgnoreCase))
643+
{
644+
editorSession.PowerShellContext.AbortExecution();
645+
}
646+
else if (string.Equals("!break", evaluateParams.Expression, StringComparison.CurrentCultureIgnoreCase))
647+
{
648+
editorSession.DebugService.Break();
649+
}
650+
else
651+
{
652+
// Send the input through the console service
653+
editorSession.ConsoleService.ExecuteCommand(
654+
evaluateParams.Expression,
655+
false);
656+
}
645657
}
646658
else
647659
{

0 commit comments

Comments
 (0)