Skip to content

Commit 638a066

Browse files
committed
Don't call PowerShell.BeginStop when stopped in the debugger
1 parent f8042db commit 638a066

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,6 @@ protected async Task HandleDisconnectRequest(
324324
{
325325
await requestContext.SendResult(null);
326326
this.editorSession.PowerShellContext.SessionStateChanged -= handler;
327-
328-
// Stop the server
329-
await this.Stop();
330327
}
331328
};
332329

src/PowerShellEditorServices/Session/PowerShellContext.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,13 +706,16 @@ public void AbortExecution()
706706
{
707707
Logger.Write(LogLevel.Verbose, "Execution abort requested...");
708708

709-
this.powerShell.BeginStop(null, null);
710-
this.SessionState = PowerShellContextState.Aborting;
711-
712709
if (this.IsDebuggerStopped)
713710
{
714711
this.ResumeDebugger(DebuggerResumeAction.Stop);
715712
}
713+
else
714+
{
715+
this.powerShell.BeginStop(null, null);
716+
}
717+
718+
this.SessionState = PowerShellContextState.Aborting;
716719
}
717720
else
718721
{
@@ -1114,7 +1117,6 @@ private static SessionStateChangedEventArgs TranslateInvocationStateInfo(PSInvoc
11141117
break;
11151118

11161119
case PSInvocationState.Stopping:
1117-
// TODO: Collapse this so that the result shows that execution was aborted
11181120
newState = PowerShellContextState.Aborting;
11191121
break;
11201122

test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ await this.AssertStateChange(
474474
this.debugService.Abort();
475475
await this.AssertStateChange(
476476
PowerShellContextState.Ready,
477-
PowerShellExecutionResult.Aborted);
477+
PowerShellExecutionResult.Completed);
478478
}
479479

480480
[Fact]
@@ -497,7 +497,7 @@ await this.AssertStateChange(
497497
this.debugService.Abort();
498498
await this.AssertStateChange(
499499
PowerShellContextState.Ready,
500-
PowerShellExecutionResult.Aborted);
500+
PowerShellExecutionResult.Completed);
501501
}
502502

503503
[Fact]

0 commit comments

Comments
 (0)