Skip to content
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