Skip to content

Commit 7986cd3

Browse files
authored
when being invoked with an explict position then make sure to show above that (microsoft#196604)
fixes microsoft/vscode-copilot#2273
1 parent 272653c commit 7986cd3

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,12 @@ export class InlineChatController implements IEditorContribution {
236236

237237
// ---- state machine
238238

239-
private _showWidget(initialRender: boolean = false, position?: IPosition) {
239+
private _showWidget(initialRender: boolean = false, position?: Position) {
240240
assertType(this._editor.hasModel());
241241

242242
let widgetPosition = position
243-
? Position.lift(position)
244-
: this._zone.value.position ?? this._editor.getSelection().getStartPosition().delta(-1);
243+
?? this._zone.value.position
244+
?? this._editor.getSelection().getStartPosition().delta(-1);
245245

246246
let needsMargin = false;
247247
if (initialRender) {
@@ -275,7 +275,15 @@ export class InlineChatController implements IEditorContribution {
275275

276276
let session: Session | undefined = options.existingSession;
277277

278-
this._showWidget(true, options.position);
278+
279+
let initPosition: Position | undefined;
280+
if (options.position) {
281+
initPosition = Position.lift(options.position).delta(-1);
282+
delete options.position;
283+
}
284+
285+
this._showWidget(true, initPosition);
286+
279287
this._zone.value.widget.updateInfo(localize('welcome.1', "AI-generated code may be incorrect"));
280288
this._updatePlaceholder();
281289

@@ -366,7 +374,7 @@ export class InlineChatController implements IEditorContribution {
366374
this._zone.value.widget.selectAll();
367375
}
368376

369-
this._showWidget(true, options.position);
377+
this._showWidget(true);
370378

371379
this._sessionStore.add(this._editor.onDidChangeModel((e) => {
372380
const msg = this._activeSession?.lastExchange

0 commit comments

Comments
 (0)