Skip to content

Commit 1556ef5

Browse files
committed
Await ExecutePSCommandAsync in evaluate handlers
1 parent f890a75 commit 1556ef5

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ public async Task<EvaluateResponseBody> Handle(EvaluateRequestArguments request,
4747

4848
if (isFromRepl)
4949
{
50-
_executionService.ExecutePSCommandAsync(
50+
await _executionService.ExecutePSCommandAsync(
5151
new PSCommand().AddScript(request.Expression),
5252
CancellationToken.None,
53-
new PowerShellExecutionOptions { WriteOutputToHost = true, ThrowOnError = false, AddToHistory = true }).HandleErrorsAsync(_logger);
53+
new PowerShellExecutionOptions { WriteOutputToHost = true, ThrowOnError = false, AddToHistory = true }).HandleErrorsAsync(_logger).ConfigureAwait(false);
5454
}
5555
else
5656
{

src/PowerShellEditorServices/Services/PowerShell/Handlers/EvaluateHandler.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,22 @@ public EvaluateHandler(
2828
_executionService = executionService;
2929
}
3030

31-
public Task<EvaluateResponseBody> Handle(EvaluateRequestArguments request, CancellationToken cancellationToken)
31+
public async Task<EvaluateResponseBody> Handle(EvaluateRequestArguments request, CancellationToken cancellationToken)
3232
{
3333
// TODO: Understand why we currently handle this asynchronously and why we return a dummy result value
3434
// instead of awaiting the execution and returing a real result of some kind
3535

3636
// This API is mostly used for F8 execution, so needs to interrupt the command prompt
37-
_executionService.ExecutePSCommandAsync(
37+
await _executionService.ExecutePSCommandAsync(
3838
new PSCommand().AddScript(request.Expression),
3939
CancellationToken.None,
40-
new PowerShellExecutionOptions { WriteInputToHost = true, WriteOutputToHost = true, AddToHistory = true, ThrowOnError = false, InterruptCurrentForeground = true })
41-
.HandleErrorsAsync(_logger);
40+
new PowerShellExecutionOptions { WriteInputToHost = true, WriteOutputToHost = true, AddToHistory = true, ThrowOnError = false, InterruptCurrentForeground = true }).ConfigureAwait(false);
4241

43-
return Task.FromResult(new EvaluateResponseBody
42+
return new EvaluateResponseBody
4443
{
4544
Result = "",
4645
VariablesReference = 0
47-
});
46+
};
4847
}
4948
}
5049
}

0 commit comments

Comments
 (0)