@@ -67,7 +67,6 @@ export interface InteractiveEditorRunOptions {
67
67
autoSend ?: boolean ;
68
68
existingSession ?: Session ;
69
69
isUnstashed ?: boolean ;
70
- initialRender ?: boolean ;
71
70
}
72
71
73
72
export class InteractiveEditorController implements IEditorContribution {
@@ -238,12 +237,16 @@ export class InteractiveEditorController implements IEditorContribution {
238
237
this . _initializeStratetgy ( session ) ;
239
238
this . _activeSession = session ;
240
239
this . _store . add ( this . _configurationService . onDidChangeConfiguration ( ( e ) => {
240
+
241
241
console . log ( 'e : ' , e ) ;
242
242
console . log ( 'e.affectsConfiguration(interactiveEditor.editModes) : ' , e . affectsConfiguration ( 'interactiveEditor.editMode' ) ) ;
243
243
console . log ( 'this._activeSession : ' , this . _activeSession ) ;
244
+
244
245
if ( e . affectsConfiguration ( 'interactiveEditor.editMode' ) ) {
246
+
245
247
console . log ( 'entered into inner if loop of onDidChangeConfiguration' ) ;
246
248
console . log ( 'this._getMode() : ' , this . _getMode ( ) ) ;
249
+
247
250
this . _updateEditMode = true ;
248
251
}
249
252
} ) ) ;
@@ -252,7 +255,9 @@ export class InteractiveEditorController implements IEditorContribution {
252
255
}
253
256
254
257
private _initializeStratetgy ( session : Session ) : void {
258
+
255
259
console . log ( 'inside of initial strategy' ) ;
260
+
256
261
switch ( session . editMode ) {
257
262
case EditMode . Live :
258
263
this . _strategy = this . _instaService . createInstance ( LiveStrategy , session , this . _editor , this . _zone . value . widget ) ;
@@ -267,24 +272,49 @@ export class InteractiveEditorController implements IEditorContribution {
267
272
}
268
273
}
269
274
270
- private _showWidget ( initialRender : boolean = false ) {
275
+ private _showWidget ( initialRender : boolean = false , updateEditMode : boolean = false ) {
276
+
271
277
console . log ( 'inside of _showWidget' ) ;
272
278
console . log ( 'initialRender : ' , initialRender ) ;
279
+ console . log ( 'updateEditMode : ' , updateEditMode ) ;
280
+
273
281
assertType ( this . _activeSession ) ;
274
282
const selectionRange = this . _activeSession . wholeRange . value ;
275
283
276
284
if ( ! initialRender ) {
285
+ console . log ( 'initial render is false' ) ;
286
+ console . log ( 'this._activeSession.lastPosition : ' , this . _activeSession . lastPosition ) ;
277
287
if ( this . _activeSession . lastPosition ) {
278
- this . _zone . value . showWidget ( selectionRange , this . _activeSession . lastPosition ) ;
288
+ console . log ( 'inside if' ) ;
289
+ if ( updateEditMode ) {
290
+ console . log ( 'inside if' ) ;
291
+ this . _zone . value . showWidget ( selectionRange , this . _strategy ?. getWidgetPosition ( initialRender , selectionRange ) ) ;
292
+ } else {
293
+ console . log ( 'inside else' ) ;
294
+ this . _zone . value . showWidget ( selectionRange , this . _activeSession . lastPosition ) ;
295
+ }
279
296
} else {
297
+ console . log ( 'inside else' ) ;
280
298
const widgetPosition = this . _strategy ?. getWidgetPosition ( initialRender , selectionRange ) ;
281
299
this . _activeSession . lastPosition = widgetPosition ;
282
300
this . _zone . value . showWidget ( selectionRange , widgetPosition ) ;
283
301
}
284
302
} else {
303
+ console . log ( 'initial render is true' ) ;
304
+ console . log ( 'this._activeSession.lastPosition : ' , this . _activeSession . lastPosition ) ;
305
+
285
306
if ( this . _activeSession . lastPosition ) {
286
- this . _zone . value . showWidget ( selectionRange , this . _activeSession . lastPosition ) ;
307
+ console . log ( 'inside if' ) ;
308
+ if ( updateEditMode ) {
309
+ console . log ( 'inside if' ) ;
310
+ this . _zone . value . showWidget ( selectionRange , this . _strategy ?. getWidgetPosition ( initialRender , selectionRange ) ) ;
311
+ this . _activeSession . lastPosition = undefined ;
312
+ } else {
313
+ console . log ( 'inside else' ) ;
314
+ this . _zone . value . showWidget ( selectionRange , this . _activeSession . lastPosition ) ;
315
+ }
287
316
} else {
317
+ console . log ( 'inside else' ) ;
288
318
this . _zone . value . showWidget ( selectionRange , this . _strategy ?. getWidgetPosition ( initialRender , selectionRange ) ) ;
289
319
}
290
320
}
@@ -296,7 +326,6 @@ export class InteractiveEditorController implements IEditorContribution {
296
326
if ( this . _updateEditMode ) {
297
327
this . _activeSession . editMode = this . _getMode ( ) ;
298
328
this . _initializeStratetgy ( this . _activeSession ) ;
299
- this . _updateEditMode = false ;
300
329
}
301
330
302
331
// hide/cancel inline completions when invoking IE
@@ -317,9 +346,11 @@ export class InteractiveEditorController implements IEditorContribution {
317
346
this . _zone . value . widget . value = this . _activeSession . lastInput ?? '' ;
318
347
this . _zone . value . widget . updateInfo ( this . _activeSession . session . message ?? localize ( 'welcome.1' , "AI-generated code may be incorrect" ) ) ;
319
348
this . _zone . value . widget . preferredExpansionState = this . _activeSession . lastExpansionState ;
349
+
320
350
console . log ( 'inside of init ui before show widget' ) ;
351
+
321
352
this . _initialRender = true ;
322
- this . _showWidget ( this . _initialRender ) ;
353
+ this . _showWidget ( this . _initialRender , this . _updateEditMode ) ;
323
354
324
355
this . _sessionStore . add ( this . _editor . onDidChangeModel ( ( e ) => {
325
356
const msg = this . _activeSession ?. lastExchange
@@ -407,10 +438,13 @@ export class InteractiveEditorController implements IEditorContribution {
407
438
private async [ State . WAIT_FOR_INPUT ] ( options : InteractiveEditorRunOptions | undefined ) : Promise < State . ACCEPT | State . CANCEL | State . PAUSE | State . WAIT_FOR_INPUT | State . MAKE_REQUEST > {
408
439
assertType ( this . _activeSession ) ;
409
440
441
+
410
442
console . log ( 'inside of wait for input' ) ;
443
+
411
444
this . _zone . value . widget . placeholder = this . _getPlaceholderText ( ) ;
412
- this . _showWidget ( this . _initialRender ) ;
445
+ this . _showWidget ( this . _initialRender , this . _updateEditMode ) ;
413
446
this . _initialRender = false ;
447
+ this . _updateEditMode = false ;
414
448
415
449
if ( options ?. message ) {
416
450
this . _zone . value . widget . value = options ?. message ;
@@ -449,7 +483,9 @@ export class InteractiveEditorController implements IEditorContribution {
449
483
}
450
484
451
485
if ( ! this . _zone . value . widget . value ) {
486
+
452
487
console . log ( 'before the case when we call WAIT_FOR_INPUT' ) ;
488
+
453
489
return State . WAIT_FOR_INPUT ;
454
490
}
455
491
@@ -479,7 +515,9 @@ export class InteractiveEditorController implements IEditorContribution {
479
515
private async [ State . MAKE_REQUEST ] ( ) : Promise < State . APPLY_RESPONSE | State . PAUSE | State . CANCEL | State . ACCEPT > {
480
516
assertType ( this . _editor . hasModel ( ) ) ;
481
517
assertType ( this . _activeSession ) ;
518
+
482
519
console . log ( 'this._activeSession.lastInput : ' , this . _activeSession . lastInput ) ;
520
+
483
521
assertType ( this . _activeSession . lastInput ) ;
484
522
485
523
const requestCts = new CancellationTokenSource ( ) ;
0 commit comments