@@ -271,24 +271,18 @@ export class XtabProvider implements IStatelessNextEditProvider {
271
271
272
272
telemetryBuilder . setNLinesOfCurrentFileInPrompt ( nLinesCurrentFile ) ;
273
273
274
- const recordingEnabled = this . configService . getConfig < boolean > ( ConfigKey . Internal . InlineEditsLogContextRecorderEnabled ) ;
275
-
276
- let langCtx : LanguageContextResponse | undefined ;
277
- if ( promptOptions . languageContext . enabled || recordingEnabled ) {
278
- const langCtxPromise = this . getLanguageContext ( request , delaySession , activeDocument , cursorPosition , logContext , cancellationToken ) ;
279
-
280
- if ( promptOptions . languageContext . enabled ) {
281
- langCtx = await langCtxPromise ;
282
- }
274
+ const langCtx = await this . getAndProcessLanguageContext (
275
+ request ,
276
+ delaySession ,
277
+ activeDocument ,
278
+ cursorPosition ,
279
+ promptOptions ,
280
+ logContext ,
281
+ cancellationToken ,
282
+ ) ;
283
283
284
- if ( recordingEnabled ) {
285
- logContext . setFileDiagnostics ( this . langDiagService . getAllDiagnostics ( ) ) ;
286
- langCtxPromise . then ( langCtxs => {
287
- if ( langCtxs ) {
288
- logContext . setLanguageContext ( langCtxs ) ;
289
- }
290
- } ) ;
291
- }
284
+ if ( cancellationToken . isCancellationRequested ) {
285
+ return Result . error ( new NoNextEditReason . GotCancelled ( 'afterLanguageContextAwait' ) ) ;
292
286
}
293
287
294
288
const promptPieces = new PromptPieces (
@@ -420,6 +414,38 @@ export class XtabProvider implements IStatelessNextEditProvider {
420
414
} ) ) ;
421
415
}
422
416
417
+ private getAndProcessLanguageContext (
418
+ request : StatelessNextEditRequest ,
419
+ delaySession : DelaySession ,
420
+ activeDocument : StatelessNextEditDocument ,
421
+ cursorPosition : Position ,
422
+ promptOptions : ModelConfig ,
423
+ logContext : InlineEditRequestLogContext ,
424
+ cancellationToken : CancellationToken ,
425
+ ) : Promise < LanguageContextResponse | undefined > {
426
+ const recordingEnabled = this . configService . getConfig < boolean > ( ConfigKey . Internal . InlineEditsLogContextRecorderEnabled ) ;
427
+
428
+ if ( ! promptOptions . languageContext . enabled && ! recordingEnabled ) {
429
+ return Promise . resolve ( undefined ) ;
430
+ }
431
+
432
+ const langCtxPromise = this . getLanguageContext ( request , delaySession , activeDocument , cursorPosition , logContext , cancellationToken ) ;
433
+
434
+ // if recording, add diagnostics for the file to the recording and hook up the language context promise to write to the recording
435
+ if ( recordingEnabled ) {
436
+ logContext . setFileDiagnostics ( this . langDiagService . getAllDiagnostics ( ) ) ;
437
+ langCtxPromise . then ( langCtxs => {
438
+ if ( langCtxs ) {
439
+ logContext . setLanguageContext ( langCtxs ) ;
440
+ }
441
+ } ) ;
442
+ }
443
+
444
+ return promptOptions . languageContext . enabled
445
+ ? langCtxPromise
446
+ : Promise . resolve ( undefined ) ;
447
+ }
448
+
423
449
424
450
private async getLanguageContext (
425
451
request : StatelessNextEditRequest ,
0 commit comments