@@ -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,14 @@ export class InlineChatController implements IEditorContribution {
184
185
185
186
// ---- state machine
186
187
187
- private _showWidget ( initialRender : boolean = false ) {
188
+ // TODO: maybe should instead use the position inside of the line number?
189
+ // Makes the code more difficult but more coherent
190
+ private _showWidget ( initialRender : boolean = false , position ?: IPosition ) {
188
191
assertType ( this . _editor . hasModel ( ) ) ;
189
192
190
193
let widgetPosition : Position ;
191
194
if ( initialRender ) {
192
- widgetPosition = this . _editor . getSelection ( ) . getEndPosition ( ) ;
195
+ widgetPosition = position ? Position . lift ( position ) : this . _editor . getSelection ( ) . getEndPosition ( ) ;
193
196
this . _zone . value . setContainerMargins ( ) ;
194
197
this . _zone . value . setWidgetMargins ( widgetPosition ) ;
195
198
} else {
@@ -219,7 +222,8 @@ export class InlineChatController implements IEditorContribution {
219
222
220
223
let session : Session | undefined = options . existingSession ;
221
224
222
- this . _showWidget ( true ) ;
225
+ console . log ( 'options : ' , options ) ;
226
+ this . _showWidget ( true , options . position ) ;
223
227
this . _zone . value . widget . updateInfo ( localize ( 'welcome.1' , "AI-generated code may be incorrect" ) ) ;
224
228
this . _zone . value . widget . placeholder = this . _getPlaceholderText ( ) ;
225
229
@@ -307,7 +311,8 @@ export class InlineChatController implements IEditorContribution {
307
311
}
308
312
} ) ;
309
313
310
- this . _showWidget ( true ) ;
314
+ console . log ( 'options : ' , options ) ;
315
+ this . _showWidget ( true , options . position ) ;
311
316
312
317
this . _sessionStore . add ( this . _editor . onDidChangeModel ( ( e ) => {
313
318
const msg = this . _activeSession ?. lastExchange
0 commit comments