From 54b6ab9049474c70992025f6d9589ac24d9e8b4c Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 16 Feb 2022 12:48:05 -0800 Subject: [PATCH] Avoid stopping the debugger when canceling other tasks in a debug session While we need to cancel the debugger if a debugged task is running and Ctrl-C is issued, we explicitly are not running the debugged task when we're stopped in a breakpoint. Instead, the user can be running unrelated tasks and may wish to cancel them without stopping the debugger. --- .../Services/PowerShell/Host/PsesInternalHost.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs index 5e790037d..4fd02ef34 100644 --- a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs +++ b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs @@ -861,8 +861,12 @@ private void OnCancelKeyPress(object sender, ConsoleCancelEventArgs args) _cancellationContext.CancelCurrentTask(); // If the current task was running under the debugger, we need to synchronize the - // cancelation with our debug context (and likely the debug server). - StopDebugContext(); + // cancelation with our debug context (and likely the debug server). Note that if we're + // currently stopped in a breakpoint, that means the task is _not_ under the debugger. + if (!CurrentRunspace.Runspace.Debugger.InBreakpoint) + { + StopDebugContext(); + } } private ConsoleKeyInfo ReadKey(bool intercept)