@@ -240,16 +240,19 @@ export class InlineCompletionService {
240
240
}
241
241
242
242
async clearInlineCompletionStates ( editor : vscode . TextEditor | undefined ) {
243
- await HoverConfigUtil . instance . restoreHoverConfig ( )
244
- vsCodeState . isCodeWhispererEditing = false
245
- ReferenceInlineProvider . instance . removeInlineReference ( )
246
- RecommendationHandler . instance . cancelPaginatedRequest ( )
247
- RecommendationHandler . instance . reportUserDecisionOfCurrentRecommendation ( editor , - 1 )
248
- RecommendationHandler . instance . clearRecommendations ( )
249
- this . disposeInlineCompletion ( )
250
- this . setCodeWhispererStatusBarOk ( )
251
- this . disposeCommandOverrides ( )
252
- this . clearRejectionTimer ( )
243
+ try {
244
+ vsCodeState . isCodeWhispererEditing = false
245
+ ReferenceInlineProvider . instance . removeInlineReference ( )
246
+ RecommendationHandler . instance . cancelPaginatedRequest ( )
247
+ RecommendationHandler . instance . reportUserDecisionOfCurrentRecommendation ( editor , - 1 )
248
+ RecommendationHandler . instance . clearRecommendations ( )
249
+ this . disposeInlineCompletion ( )
250
+ this . setCodeWhispererStatusBarOk ( )
251
+ this . disposeCommandOverrides ( )
252
+ } finally {
253
+ this . clearRejectionTimer ( )
254
+ await HoverConfigUtil . instance . restoreHoverConfig ( )
255
+ }
253
256
}
254
257
255
258
async tryShowRecommendation ( ) {
@@ -267,9 +270,8 @@ export class InlineCompletionService {
267
270
RecommendationHandler . instance . clearRecommendations ( )
268
271
} else if ( RecommendationHandler . instance . recommendations . length > 0 ) {
269
272
RecommendationHandler . instance . moveStartPositionToSkipSpaces ( editor )
270
- await HoverConfigUtil . instance . overwriteHoverConfig ( )
271
273
this . subscribeSuggestionCommands ( )
272
- this . startRejectionTimer ( editor )
274
+ await this . startRejectionTimer ( editor )
273
275
await this . showRecommendation ( 0 , true )
274
276
}
275
277
}
@@ -325,9 +327,6 @@ export class InlineCompletionService {
325
327
this . inlineCompletionProvider ?. getActiveItemIndex ,
326
328
indexShift
327
329
)
328
- this . inlineCompletionProvider . onDidShow ( e => {
329
- this . _timer ?. refresh ( )
330
- } )
331
330
this . inlineCompletionProviderDisposable ?. dispose ( )
332
331
// when suggestion is active, registering a new provider will let VS Code invoke inline API automatically
333
332
this . inlineCompletionProviderDisposable = vscode . languages . registerInlineCompletionItemProvider (
@@ -375,24 +374,25 @@ export class InlineCompletionService {
375
374
376
375
private clearRejectionTimer ( ) {
377
376
if ( this . _timer !== undefined ) {
378
- clearTimeout ( this . _timer )
377
+ clearInterval ( this . _timer )
379
378
this . _timer = undefined
380
379
}
381
380
}
382
381
383
382
/*
384
383
* This startRejectionTimer function is to mark recommendation as rejected
385
- * when the suggestions are no longer been shown to users for more than 10 seconds
384
+ * when the suggestions are no longer been shown to users for more than 5 seconds
386
385
*/
387
386
private async startRejectionTimer ( editor : vscode . TextEditor ) : Promise < void > {
388
387
if ( this . _timer !== undefined ) {
389
388
return
390
389
}
391
- this . _timer = globals . clock . setTimeout ( async ( ) => {
390
+ await HoverConfigUtil . instance . overwriteHoverConfig ( )
391
+ this . _timer = globals . clock . setInterval ( async ( ) => {
392
392
if ( ! this . isSuggestionVisible ( ) ) {
393
393
getLogger ( ) . info ( `Clearing cached suggestion` )
394
394
await this . clearInlineCompletionStates ( editor )
395
395
}
396
- } , 10 * 1000 )
396
+ } , 5 * 1000 )
397
397
}
398
398
}
0 commit comments