@@ -25,7 +25,6 @@ namespace Microsoft.PowerShell.EditorServices.Handlers
25
25
// TODO: Use ABCs.
26
26
internal class PsesCompletionHandler : ICompletionHandler , ICompletionResolveHandler
27
27
{
28
- private const int DefaultWaitTimeoutMilliseconds = 5000 ;
29
28
private readonly ILogger _logger ;
30
29
private readonly IRunspaceContext _runspaceContext ;
31
30
private readonly IInternalPowerShellExecutionService _executionService ;
@@ -60,14 +59,11 @@ public async Task<CompletionList> Handle(CompletionParams request, CancellationT
60
59
int cursorColumn = request . Position . Character + 1 ;
61
60
62
61
ScriptFile scriptFile = _workspaceService . GetFile ( request . TextDocument . Uri ) ;
63
-
64
- if ( cancellationToken . IsCancellationRequested )
65
- {
66
- _logger . LogDebug ( "Completion request canceled for file: {0}" , request . TextDocument . Uri ) ;
67
- return Array . Empty < CompletionItem > ( ) ;
68
- }
69
-
70
- IEnumerable < CompletionItem > completionResults = await GetCompletionsInFileAsync ( scriptFile , cursorLine , cursorColumn ) . ConfigureAwait ( false ) ;
62
+ IEnumerable < CompletionItem > completionResults = await GetCompletionsInFileAsync (
63
+ scriptFile ,
64
+ cursorLine ,
65
+ cursorColumn ,
66
+ cancellationToken ) . ConfigureAwait ( false ) ;
71
67
72
68
return new CompletionList ( completionResults ) ;
73
69
}
@@ -133,21 +129,18 @@ public void SetCapability(CompletionCapability capability, ClientCapabilities cl
133
129
public async Task < IEnumerable < CompletionItem > > GetCompletionsInFileAsync (
134
130
ScriptFile scriptFile ,
135
131
int lineNumber ,
136
- int columnNumber )
132
+ int columnNumber ,
133
+ CancellationToken cancellationToken )
137
134
{
138
135
Validate . IsNotNull ( nameof ( scriptFile ) , scriptFile ) ;
139
136
140
- CommandCompletion result = null ;
141
- using ( CancellationTokenSource cts = new ( DefaultWaitTimeoutMilliseconds ) )
142
- {
143
- result = await AstOperations . GetCompletionsAsync (
144
- scriptFile . ScriptAst ,
145
- scriptFile . ScriptTokens ,
146
- scriptFile . GetOffsetAtPosition ( lineNumber , columnNumber ) ,
147
- _executionService ,
148
- _logger ,
149
- cts . Token ) . ConfigureAwait ( false ) ;
150
- }
137
+ CommandCompletion result = await AstOperations . GetCompletionsAsync (
138
+ scriptFile . ScriptAst ,
139
+ scriptFile . ScriptTokens ,
140
+ scriptFile . GetOffsetAtPosition ( lineNumber , columnNumber ) ,
141
+ _executionService ,
142
+ _logger ,
143
+ cancellationToken ) . ConfigureAwait ( false ) ;
151
144
152
145
// Only calculate the replacement range if there are completions.
153
146
BufferRange replacedRange = new ( 0 , 0 , 0 , 0 ) ;
0 commit comments