Skip to content

Commit 169c0ed

Browse files
committed
extracting the showing into a separate code
1 parent 094052c commit 169c0ed

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ export class InteractiveEditorController implements IEditorContribution {
249249
return State.INIT_UI;
250250
}
251251

252+
private _showWidget(): void {
253+
assertType(this._activeSession);
254+
const selectionRange = this._activeSession.wholeRange.value;
255+
const position = this._strategy?.getWidgetPosition(selectionRange);
256+
this._zone.value.showWidget(selectionRange, position);
257+
}
258+
252259
private async [State.INIT_UI](options: InteractiveEditorRunOptions | undefined): Promise<State.WAIT_FOR_INPUT | State.SHOW_RESPONSE | State.APPLY_RESPONSE> {
253260
assertType(this._activeSession);
254261

@@ -269,8 +276,9 @@ export class InteractiveEditorController implements IEditorContribution {
269276
this._zone.value.widget.placeholder = this._getPlaceholderText();
270277
this._zone.value.widget.value = this._activeSession.lastInput ?? '';
271278
this._zone.value.widget.updateInfo(this._activeSession.session.message ?? localize('welcome.1', "AI-generated code may be incorrect"));
272-
this._zone.value.show(this._activeSession.wholeRange.value);
273279
this._zone.value.widget.preferredExpansionState = this._activeSession.lastExpansionState;
280+
console.log('before show of the init ui');
281+
this._showWidget();
274282

275283
this._sessionStore.add(this._editor.onDidChangeModel((e) => {
276284
const msg = this._activeSession?.lastExchange
@@ -359,7 +367,9 @@ export class InteractiveEditorController implements IEditorContribution {
359367
assertType(this._activeSession);
360368

361369
this._zone.value.widget.placeholder = this._getPlaceholderText();
362-
this._zone.value.show(this._activeSession.wholeRange.value);
370+
371+
console.log('before show of wait_for_input');
372+
this._showWidget();
363373

364374
if (options?.message) {
365375
this._zone.value.widget.value = options?.message;

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,11 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
791791
super._relayout(this._computeHeightInLines());
792792
}
793793

794-
override show(selectionRange: Range): void {
795-
super.show(selectionRange.getEndPosition(), this._computeHeightInLines());
794+
showWidget(selectionRange: Range, position: Position | undefined): void {
795+
console.log('selectionRange : ', selectionRange);
796+
console.log('position : ', position);
797+
798+
super.show(position ?? selectionRange.getEndPosition(), this._computeHeightInLines());
796799
this.widget.focus();
797800
this._ctxVisible.set(true);
798801
this._setMargins(selectionRange);

0 commit comments

Comments
 (0)