Skip to content

Fix prompt spam and general debugger reliability improvements #1762

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 2 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private void StopDebuggerIfRemoteDebugSessionFailed()

private void CancelNormalExecution()
{
if (_pwsh.Runspace.RunspaceStateInfo.IsUsable())
if (!_pwsh.Runspace.RunspaceStateInfo.IsUsable())
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,18 +680,30 @@ private void RunExecutionLoop(bool isForDebug = false)
}

using CancellationScope cancellationScope = _cancellationContext.EnterScope(false);
DoOneRepl(cancellationScope.CancellationToken);

try
{
DoOneRepl(cancellationScope.CancellationToken);
}
catch (OperationCanceledException)
{
if (isForDebug)
{
while (Runspace is { RunspaceIsRemote: true } remoteRunspace
&& !remoteRunspace.RunspaceStateInfo.IsUsable())
{
PopPowerShell(RunspaceChangeAction.Exit);
}

return;
}
}

while (!ShouldExitExecutionLoop
&& !cancellationScope.CancellationToken.IsCancellationRequested
&& _taskQueue.TryTake(out ISynchronousTask task))
{
task.ExecuteSynchronously(cancellationScope.CancellationToken);
while (Runspace is { RunspaceIsRemote: true } remoteRunspace
&& !remoteRunspace.RunspaceStateInfo.IsUsable())
{
PopPowerShell(RunspaceChangeAction.Exit);
}
}

if (_shouldExit
Expand Down Expand Up @@ -759,7 +771,7 @@ private void DoOneRepl(CancellationToken cancellationToken)
}
catch (OperationCanceledException)
{
// Do nothing, since we were just cancelled
throw;
}
// Propagate exceptions thrown from the debugger when quitting.
catch (TerminateException)
Expand Down Expand Up @@ -828,6 +840,7 @@ public void WriteWithPrompt(PSCommand command, CancellationToken cancellationTok

private string InvokeReadLine(CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
try
{
_readKeyCancellationToken = cancellationToken;
Expand Down