Skip to content

Commit 5df33bb

Browse files
Mark completion requests as Serial
This stops completion from being cancelled whenever a DidChangeTextDocument notification is sent. Also lets completion cancel some other expensive requests like code lens.
1 parent f29b4e4 commit 5df33bb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/PowerShellEditorServices/Server/PsesLanguageServer.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.PowerShell.EditorServices.Services.Extension;
1313
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Host;
1414
using Microsoft.PowerShell.EditorServices.Services.Template;
15+
using OmniSharp.Extensions.JsonRpc;
1516
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
1617
using OmniSharp.Extensions.LanguageServer.Server;
1718
using Serilog;
@@ -102,7 +103,14 @@ public async Task StartAsync()
102103
.WithHandler<PsesCodeLensHandlers>()
103104
.WithHandler<PsesCodeActionHandler>()
104105
.WithHandler<InvokeExtensionCommandHandler>()
105-
.WithHandler<PsesCompletionHandler>()
106+
// If PsesCompletionHandler is not marked as serial, then DidChangeTextDocument
107+
// notifications will end up cancelling completion. So quickly typing `Get-`
108+
// would result in no completions.
109+
//
110+
// This also lets completion requests interrupt time consuming background tasks
111+
// like the references code lens.
112+
.WithHandler<PsesCompletionHandler>(
113+
new JsonRpcHandlerOptions() { RequestProcessType = RequestProcessType.Serial })
106114
.WithHandler<PsesHoverHandler>()
107115
.WithHandler<PsesSignatureHelpHandler>()
108116
.WithHandler<PsesDefinitionHandler>()

0 commit comments

Comments
 (0)