Skip to content

Commit 584e483

Browse files
Merge pull request #1555 from PowerShell/andschwa/cancel-tokens
Fix debugger regression where console needed input to start/continue
2 parents 07362b0 + 2316a2d commit 584e483

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DisconnectHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public async Task<DisconnectResponse> Handle(DisconnectArguments request, Cancel
7474
_logger.LogInformation("Debug adapter is shutting down...");
7575

7676
#pragma warning disable CS4014
77-
// Trigger the clean up of the debugger. No need to wait for it.
78-
Task.Run(_psesDebugServer.OnSessionEnded, cancellationToken);
77+
// Trigger the clean up of the debugger. No need to wait for it nor cancel it.
78+
Task.Run(_psesDebugServer.OnSessionEnded, CancellationToken.None);
7979
#pragma warning restore CS4014
8080

8181
return new DisconnectResponse();

src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,6 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
765765
}
766766

767767
// This is the primary reason that ExecuteCommandAsync takes a CancellationToken
768-
cancellationToken.Register(() => shell.Stop());
769768
return await Task.Run<IEnumerable<TResult>>(
770769
() => shell.Invoke<TResult>(input: null, invocationSettings), cancellationToken)
771770
.ConfigureAwait(false);

src/PowerShellEditorServices/Services/PowerShellContext/Session/PSReadLinePromptContext.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ public async Task<string> InvokeReadLineAsync(bool isCommandLine, CancellationTo
144144
readLineCommand,
145145
errorMessages: null,
146146
s_psrlExecutionOptions,
147-
cancellationToken).ConfigureAwait(false);
147+
// NOTE: This command should always be allowed to complete, as the command itself
148+
// has a linked cancellation token such that PSReadLine will be correctly cancelled.
149+
CancellationToken.None).ConfigureAwait(false);
148150

149151
string line = readLineResults.FirstOrDefault();
150152

src/PowerShellEditorServices/Services/Symbols/Vistors/AstOperations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static async Task<CommandCompletion> GetCompletionsAsync(
6262
ILogger logger,
6363
CancellationToken cancellationToken)
6464
{
65-
if (!s_completionHandle.Wait(0, cancellationToken))
65+
if (!s_completionHandle.Wait(0, CancellationToken.None))
6666
{
6767
return null;
6868
}

0 commit comments

Comments
 (0)