@@ -14,7 +14,7 @@ import { StopWatch } from 'vs/base/common/stopwatch';
14
14
import { assertType } from 'vs/base/common/types' ;
15
15
import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
16
16
import { EditOperation } from 'vs/editor/common/core/editOperation' ;
17
- import { Position } from 'vs/editor/common/core/position' ;
17
+ import { IPosition , Position } from 'vs/editor/common/core/position' ;
18
18
import { IRange , Range } from 'vs/editor/common/core/range' ;
19
19
import { IEditorContribution , ScrollType } from 'vs/editor/common/editorCommon' ;
20
20
import { ModelDecorationOptions , createTextBufferFactoryFromSnapshot } from 'vs/editor/common/model/textModel' ;
@@ -66,6 +66,7 @@ export interface InlineChatRunOptions {
66
66
autoSend ?: boolean ;
67
67
existingSession ?: Session ;
68
68
isUnstashed ?: boolean ;
69
+ position ?: IPosition ;
69
70
}
70
71
71
72
export class InlineChatController implements IEditorContribution {
@@ -184,12 +185,12 @@ export class InlineChatController implements IEditorContribution {
184
185
185
186
// ---- state machine
186
187
187
- private _showWidget ( initialRender : boolean = false ) {
188
+ private _showWidget ( initialRender : boolean = false , position ?: IPosition ) {
188
189
assertType ( this . _editor . hasModel ( ) ) ;
189
190
190
191
let widgetPosition : Position ;
191
192
if ( initialRender ) {
192
- widgetPosition = this . _editor . getSelection ( ) . getEndPosition ( ) ;
193
+ widgetPosition = position ? Position . lift ( position ) : this . _editor . getSelection ( ) . getEndPosition ( ) ;
193
194
this . _zone . value . setContainerMargins ( ) ;
194
195
this . _zone . value . setWidgetMargins ( widgetPosition ) ;
195
196
} else {
@@ -219,7 +220,7 @@ export class InlineChatController implements IEditorContribution {
219
220
220
221
let session : Session | undefined = options . existingSession ;
221
222
222
- this . _showWidget ( true ) ;
223
+ this . _showWidget ( true , options . position ) ;
223
224
this . _zone . value . widget . updateInfo ( localize ( 'welcome.1' , "AI-generated code may be incorrect" ) ) ;
224
225
this . _zone . value . widget . placeholder = this . _getPlaceholderText ( ) ;
225
226
@@ -307,7 +308,7 @@ export class InlineChatController implements IEditorContribution {
307
308
}
308
309
} ) ;
309
310
310
- this . _showWidget ( true ) ;
311
+ this . _showWidget ( true , options . position ) ;
311
312
312
313
this . _sessionStore . add ( this . _editor . onDidChangeModel ( ( e ) => {
313
314
const msg = this . _activeSession ?. lastExchange
0 commit comments