@@ -22,6 +22,7 @@ import { coalesce } from '../../../util/vs/base/common/arrays';
2222import { assertNever , softAssert } from '../../../util/vs/base/common/assert' ;
2323import { raceCancellation , raceTimeout } from '../../../util/vs/base/common/async' ;
2424import { CancellationToken , CancellationTokenSource } from '../../../util/vs/base/common/cancellation' ;
25+ import { Emitter } from '../../../util/vs/base/common/event' ;
2526import { Disposable , DisposableStore } from '../../../util/vs/base/common/lifecycle' ;
2627import { autorun , derived , derivedDisposable , observableFromEvent } from '../../../util/vs/base/common/observable' ;
2728import { StopWatch } from '../../../util/vs/base/common/stopwatch' ;
@@ -251,7 +252,8 @@ type LastNesSuggestion = {
251252
252253class JointCompletionsProvider extends Disposable implements vscode . InlineCompletionItemProvider {
253254
254- public onDidChange ?: vscode . Event < void > | undefined ;
255+ private _onDidChange = this . _register ( new Emitter < void > ( ) ) ;
256+ public readonly onDidChange = this . _onDidChange . event ;
255257
256258 constructor (
257259 private readonly _completionsProvider : CopilotInlineCompletionItemProvider | undefined ,
@@ -261,7 +263,14 @@ class JointCompletionsProvider extends Disposable implements vscode.InlineComple
261263 @ILogService private readonly _logService : ILogService ,
262264 ) {
263265 super ( ) ;
264- this . onDidChange = _inlineEditProvider ?. onDidChange ;
266+ if ( this . _inlineEditProvider && this . _inlineEditProvider . onDidChange ) {
267+ this . _register ( this . _inlineEditProvider . onDidChange ( ( ) => {
268+ this . _onDidChange . fire ( ) ;
269+ // if (this._isDoingCompletionsRequest === 0) {
270+ // // Never report a change event which would cause an interruption to the completions request.
271+ // }
272+ } ) ) ;
273+ }
265274 softAssert (
266275 _completionsProvider ?. onDidChange === undefined ,
267276 'CompletionsProvider does not implement onDidChange'
@@ -282,6 +291,7 @@ class JointCompletionsProvider extends Disposable implements vscode.InlineComple
282291 }
283292
284293 private lastNesSuggestion : null | LastNesSuggestion = null ;
294+ // private _isDoingCompletionsRequest = 0;
285295 private provideInlineCompletionItemsInvocationCount = 0 ;
286296
287297 private async provideInlineCompletionItemsRegular ( document : vscode . TextDocument , position : vscode . Position , context : vscode . InlineCompletionContext , token : vscode . CancellationToken , tracer : ITracer ) : Promise < SingularCompletionList | undefined > {
@@ -369,13 +379,14 @@ class JointCompletionsProvider extends Disposable implements vscode.InlineComple
369379 // prefer completions unless there are none
370380 tracer . trace ( `no last NES suggestion to consider` ) ;
371381 const completionsP = this . _invokeCompletionsProvider ( tracer , document , position , context , tokens , sw ) ;
372- const nesP = this . _invokeNESProvider ( tracer , document , position , context , tokens , sw ) ;
382+ const nesP = this . _invokeNESProvider ( tracer , document , position , false , context , tokens , sw ) ;
373383 return this . _returnCompletionsOrOtherwiseNES ( completionsP , nesP , sw , tracer , tokens ) ;
374384 }
375385
376386 tracer . trace ( `last NES suggestion is for the current document, checking if it agrees with the current suggestion` ) ;
377387
378- const nesP = this . _invokeNESProvider ( tracer , document , position , context , tokens , sw ) ;
388+ const eliminateDebouncing = ( lastNesSuggestion . docVersionId === document . version ) ;
389+ const nesP = this . _invokeNESProvider ( tracer , document , position , eliminateDebouncing , context , tokens , sw ) ;
379390 if ( ! nesP ) {
380391 tracer . trace ( `no NES provider` ) ;
381392 const completionsP = this . _invokeCompletionsProvider ( tracer , document , position , context , tokens , sw ) ;
@@ -443,7 +454,7 @@ class JointCompletionsProvider extends Disposable implements vscode.InlineComple
443454 return this . _returnCompletionsOrOtherwiseNES ( completionsP , nesP , sw , tracer , tokens ) ;
444455 }
445456
446- private _invokeNESProvider ( tracer : ITracer , document : vscode . TextDocument , position : vscode . Position , context : vscode . InlineCompletionContext , tokens : { coreToken : CancellationToken ; completionsCts : CancellationTokenSource ; nesCts : CancellationTokenSource } , sw : StopWatch ) {
457+ private _invokeNESProvider ( tracer : ITracer , document : vscode . TextDocument , position : vscode . Position , eliminateDebouncing : boolean , context : vscode . InlineCompletionContext , tokens : { coreToken : CancellationToken ; completionsCts : CancellationTokenSource ; nesCts : CancellationTokenSource } , sw : StopWatch ) {
447458 let nesP : Promise < NesCompletionList | undefined > | undefined ;
448459 if ( this . _inlineEditProvider ) {
449460 tracer . trace ( `- requesting NES provideInlineCompletionItems` ) ;
0 commit comments