@@ -44,6 +44,7 @@ export class InlineCompletionsModel extends Disposable {
44
44
private readonly _isActive = observableValue < boolean > ( this , false ) ;
45
45
private readonly _onlyRequestInlineEditsSignal = observableSignal ( this ) ;
46
46
private readonly _forceUpdateExplicitlySignal = observableSignal ( this ) ;
47
+ private readonly _noDelaySignal = observableSignal ( this ) ;
47
48
48
49
// We use a semantic id to keep the same inline completion selected even if the provider reorders the completions.
49
50
private readonly _selectedInlineCompletionId = observableValue < string | undefined > ( this , undefined ) ;
@@ -167,6 +168,7 @@ export class InlineCompletionsModel extends Disposable {
167
168
preserveCurrentCompletion : false ,
168
169
inlineCompletionTriggerKind : InlineCompletionTriggerKind . Automatic ,
169
170
onlyRequestInlineEdits : false ,
171
+ shouldDebounce : true ,
170
172
} ) ,
171
173
handleChange : ( ctx , changeSummary ) => {
172
174
/** @description fetch inline completions */
@@ -178,10 +180,13 @@ export class InlineCompletionsModel extends Disposable {
178
180
changeSummary . dontRefetch = true ;
179
181
} else if ( ctx . didChange ( this . _onlyRequestInlineEditsSignal ) ) {
180
182
changeSummary . onlyRequestInlineEdits = true ;
183
+ } else if ( ctx . didChange ( this . _noDelaySignal ) ) {
184
+ changeSummary . shouldDebounce = false ;
181
185
}
182
186
return true ;
183
187
} ,
184
188
} , ( reader , changeSummary ) => {
189
+ this . _noDelaySignal . read ( reader ) ;
185
190
this . dontRefetchSignal . read ( reader ) ;
186
191
this . _onlyRequestInlineEditsSignal . read ( reader ) ;
187
192
this . _forceUpdateExplicitlySignal . read ( reader ) ;
@@ -220,14 +225,17 @@ export class InlineCompletionsModel extends Disposable {
220
225
const itemToPreserveCandidate = this . selectedInlineCompletion . get ( ) ?? this . _inlineCompletionItems . get ( ) ?. inlineEdit ;
221
226
const itemToPreserve = changeSummary . preserveCurrentCompletion || itemToPreserveCandidate ?. forwardStable
222
227
? itemToPreserveCandidate : undefined ;
223
- return this . _source . fetch ( cursorPosition , context , itemToPreserve ) ;
228
+ return this . _source . fetch ( cursorPosition , context , itemToPreserve , changeSummary . shouldDebounce ) ;
224
229
} ) ;
225
230
226
- public async trigger ( tx ?: ITransaction , onlyFetchInlineEdits : boolean = false ) : Promise < void > {
231
+ public async trigger ( tx ?: ITransaction , options ?: { onlyFetchInlineEdits ? : boolean ; noDelay ?: boolean } ) : Promise < void > {
227
232
subtransaction ( tx , tx => {
228
- if ( onlyFetchInlineEdits ) {
233
+ if ( options ?. onlyFetchInlineEdits ) {
229
234
this . _onlyRequestInlineEditsSignal . trigger ( tx ) ;
230
235
}
236
+ if ( options ?. noDelay ) {
237
+ this . _noDelaySignal . trigger ( tx ) ;
238
+ }
231
239
this . _isActive . set ( true , tx ) ;
232
240
} ) ;
233
241
await this . _fetchInlineCompletionsPromise . get ( ) ;
0 commit comments