Skip to content

Commit 652e3fc

Browse files
committed
Send EvaluateRequest after execution completes
This change modifies the way the EvaluateRequest message is handled in the LanguageServer. Previously the evaluation response would be sent back immediately since we aren't giving back an actual result. This behavior is now changed to wait until execution completes before sending the response so that the caller knows when execution has completed.
1 parent 21c3025 commit 652e3fc

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ private bool IsQueryMatch(string query, string symbolName)
737737
return symbolName.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0;
738738
}
739739

740-
protected async Task HandleEvaluateRequest(
740+
protected Task HandleEvaluateRequest(
741741
DebugAdapterMessages.EvaluateRequestArguments evaluateParams,
742742
RequestContext<DebugAdapterMessages.EvaluateResponseBody> requestContext)
743743
{
@@ -749,16 +749,25 @@ protected async Task HandleEvaluateRequest(
749749
this.editorSession.PowerShellContext.ExecuteScriptString(
750750
evaluateParams.Expression,
751751
true,
752-
true).ConfigureAwait(false);
752+
true);
753753

754-
// Return an empty result since the result value is irrelevant
755-
// for this request in the LanguageServer
756-
await requestContext.SendResult(
757-
new DebugAdapterMessages.EvaluateResponseBody
754+
// Return the execution result after the task completes so that the
755+
// caller knows when command execution completed.
756+
executeTask.ContinueWith(
757+
(task) =>
758758
{
759-
Result = "",
760-
VariablesReference = 0
759+
// Return an empty result since the result value is irrelevant
760+
// for this request in the LanguageServer
761+
return
762+
requestContext.SendResult(
763+
new DebugAdapterMessages.EvaluateResponseBody
764+
{
765+
Result = "",
766+
VariablesReference = 0
767+
});
761768
});
769+
770+
return Task.FromResult(true);
762771
}
763772

764773
#endregion

0 commit comments

Comments
 (0)