Skip to content

Commit 4c5b418

Browse files
committed
Fix PsesCompletionHandler
1 parent 01a31f9 commit 4c5b418

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,22 @@
2121

2222
namespace Microsoft.PowerShell.EditorServices.Handlers
2323
{
24+
// TODO: Use ABCs.
2425
internal class PsesCompletionHandler : ICompletionHandler, ICompletionResolveHandler
2526
{
2627
const int DefaultWaitTimeoutMilliseconds = 5000;
2728
private readonly SemaphoreSlim _completionLock = AsyncUtils.CreateSimpleLockingSemaphore();
2829
private readonly SemaphoreSlim _completionResolveLock = AsyncUtils.CreateSimpleLockingSemaphore();
29-
3030
private readonly ILogger _logger;
3131
private readonly PowerShellContextService _powerShellContextService;
3232
private readonly WorkspaceService _workspaceService;
33-
3433
private CompletionResults _mostRecentCompletions;
35-
3634
private int _mostRecentRequestLine;
37-
3835
private int _mostRecentRequestOffest;
39-
4036
private string _mostRecentRequestFile;
41-
4237
private CompletionCapability _capability;
38+
private readonly Guid _id = Guid.NewGuid();
39+
Guid ICanBeIdentifiedHandler.Id => _id;
4340

4441
public PsesCompletionHandler(
4542
ILoggerFactory factory,
@@ -51,15 +48,12 @@ public PsesCompletionHandler(
5148
_workspaceService = workspaceService;
5249
}
5350

54-
public CompletionRegistrationOptions GetRegistrationOptions()
51+
public CompletionRegistrationOptions GetRegistrationOptions(CompletionCapability capability, ClientCapabilities clientCapabilities) => new CompletionRegistrationOptions
5552
{
56-
return new CompletionRegistrationOptions
57-
{
58-
DocumentSelector = LspUtils.PowerShellDocumentSelector,
59-
ResolveProvider = true,
60-
TriggerCharacters = new[] { ".", "-", ":", "\\", "$" }
61-
};
62-
}
53+
DocumentSelector = LspUtils.PowerShellDocumentSelector,
54+
ResolveProvider = true,
55+
TriggerCharacters = new[] { ".", "-", ":", "\\", "$" }
56+
};
6357

6458
public async Task<CompletionList> Handle(CompletionParams request, CancellationToken cancellationToken)
6559
{
@@ -145,10 +139,10 @@ await CommandHelpers.GetCommandInfoAsync(
145139

146140
if (commandInfo != null)
147141
{
148-
request.Documentation =
149-
await CommandHelpers.GetCommandSynopsisAsync(
150-
commandInfo,
151-
_powerShellContextService).ConfigureAwait(false);
142+
request = request with
143+
{
144+
Documentation = await CommandHelpers.GetCommandSynopsisAsync(commandInfo, _powerShellContextService).ConfigureAwait(false)
145+
};
152146
}
153147

154148
// Send back the updated CompletionItem
@@ -160,7 +154,7 @@ await CommandHelpers.GetCommandSynopsisAsync(
160154
}
161155
}
162156

163-
public void SetCapability(CompletionCapability capability)
157+
public void SetCapability(CompletionCapability capability, ClientCapabilities clientCapabilities)
164158
{
165159
_capability = capability;
166160
}

0 commit comments

Comments
 (0)