@@ -194,6 +194,20 @@ export class InlineChatController implements IEditorContribution {
194
194
195
195
// ---- state machine
196
196
197
+ private _showWidget ( initialRender : boolean = false ) {
198
+ assertType ( this . _activeSession ) ;
199
+ assertType ( this . _strategy ) ;
200
+ assertType ( this . _editor . hasModel ( ) ) ;
201
+
202
+ let widgetPosition : Position | undefined ;
203
+ if ( initialRender ) {
204
+ widgetPosition = this . _editor . getPosition ( ) ;
205
+ } else {
206
+ widgetPosition = this . _strategy . getWidgetPosition ( ) ?? this . _zone . value . position ?? this . _activeSession . wholeRange . value . getEndPosition ( ) ;
207
+ }
208
+ this . _zone . value . show ( widgetPosition ) ;
209
+ }
210
+
197
211
protected async _nextState ( state : State , options : InlineChatRunOptions | undefined ) : Promise < void > {
198
212
this . _log ( 'setState to ' , state ) ;
199
213
const nextState = await this [ state ] ( options ) ;
@@ -270,8 +284,8 @@ export class InlineChatController implements IEditorContribution {
270
284
this . _zone . value . widget . placeholder = this . _getPlaceholderText ( ) ;
271
285
this . _zone . value . widget . value = this . _activeSession . lastInput ?. value ?? '' ;
272
286
this . _zone . value . widget . updateInfo ( this . _activeSession . session . message ?? localize ( 'welcome.1' , "AI-generated code may be incorrect" ) ) ;
273
- this . _zone . value . show ( this . _activeSession . wholeRange . value . getEndPosition ( ) ) ;
274
287
this . _zone . value . widget . preferredExpansionState = this . _activeSession . lastExpansionState ;
288
+ this . _showWidget ( true ) ;
275
289
276
290
this . _sessionStore . add ( this . _editor . onDidChangeModel ( ( e ) => {
277
291
const msg = this . _activeSession ?. lastExchange
@@ -361,7 +375,6 @@ export class InlineChatController implements IEditorContribution {
361
375
assertType ( this . _strategy ) ;
362
376
363
377
this . _zone . value . widget . placeholder = this . _getPlaceholderText ( ) ;
364
- this . _zone . value . show ( this . _activeSession . wholeRange . value . getEndPosition ( ) ) ;
365
378
366
379
if ( options ?. message ) {
367
380
this . _zone . value . widget . value = options ?. message ;
@@ -548,6 +561,7 @@ export class InlineChatController implements IEditorContribution {
548
561
assertType ( this . _strategy ) ;
549
562
550
563
const { response } = this . _activeSession . lastExchange ! ;
564
+ this . _showWidget ( false ) ;
551
565
552
566
this . _ctxLastResponseType . set ( response instanceof EditResponse || response instanceof MarkdownResponse
553
567
? response . raw . type
0 commit comments