@@ -25,7 +25,6 @@ namespace Microsoft.PowerShell.EditorServices.Handlers
2525 // TODO: Use ABCs.
2626 internal class PsesCompletionHandler : ICompletionHandler , ICompletionResolveHandler
2727 {
28- private const int DefaultWaitTimeoutMilliseconds = 5000 ;
2928 private readonly ILogger _logger ;
3029 private readonly IRunspaceContext _runspaceContext ;
3130 private readonly IInternalPowerShellExecutionService _executionService ;
@@ -60,14 +59,11 @@ public async Task<CompletionList> Handle(CompletionParams request, CancellationT
6059 int cursorColumn = request . Position . Character + 1 ;
6160
6261 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 ) ;
7167
7268 return new CompletionList ( completionResults ) ;
7369 }
@@ -133,21 +129,18 @@ public void SetCapability(CompletionCapability capability, ClientCapabilities cl
133129 public async Task < IEnumerable < CompletionItem > > GetCompletionsInFileAsync (
134130 ScriptFile scriptFile ,
135131 int lineNumber ,
136- int columnNumber )
132+ int columnNumber ,
133+ CancellationToken cancellationToken )
137134 {
138135 Validate . IsNotNull ( nameof ( scriptFile ) , scriptFile ) ;
139136
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 ) ;
151144
152145 // Only calculate the replacement range if there are completions.
153146 BufferRange replacedRange = new ( 0 , 0 , 0 , 0 ) ;
0 commit comments