Skip to content

Commit e05a47d

Browse files
committed
taking into account the last rendering position of the active session
1 parent aa4daa4 commit e05a47d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,22 @@ export class InteractiveEditorController implements IEditorContribution {
272272
console.log('initialRender : ', initialRender);
273273
assertType(this._activeSession);
274274
const selectionRange = this._activeSession.wholeRange.value;
275-
this._zone.value.showWidget(selectionRange, this._strategy?.getWidgetPosition(initialRender, selectionRange));
275+
276+
if (!initialRender) {
277+
if (this._activeSession.lastPosition) {
278+
this._zone.value.showWidget(selectionRange, this._activeSession.lastPosition);
279+
} else {
280+
const widgetPosition = this._strategy?.getWidgetPosition(initialRender, selectionRange);
281+
this._activeSession.lastPosition = widgetPosition;
282+
this._zone.value.showWidget(selectionRange, widgetPosition);
283+
}
284+
} else {
285+
if (this._activeSession.lastPosition) {
286+
this._zone.value.showWidget(selectionRange, this._activeSession.lastPosition);
287+
} else {
288+
this._zone.value.showWidget(selectionRange, this._strategy?.getWidgetPosition(initialRender, selectionRange));
289+
}
290+
}
276291
}
277292

278293
private async [State.INIT_UI](options: InteractiveEditorRunOptions | undefined): Promise<State.WAIT_FOR_INPUT | State.SHOW_RESPONSE | State.APPLY_RESPONSE> {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
2525
import { isCancellationError } from 'vs/base/common/errors';
2626
import { LineRangeMapping } from 'vs/editor/common/diff/linesDiffComputer';
2727
import { ISingleEditOperation } from 'vs/editor/common/core/editOperation';
28+
import { Position } from 'vs/editor/common/core/position';
2829

2930
export type Recording = {
3031
when: Date;
@@ -112,6 +113,7 @@ export class Session {
112113
private _lastExpansionState: ExpansionState | undefined;
113114
private _lastTextModelChanges: readonly LineRangeMapping[] | undefined;
114115
private _isUnstashed: boolean = false;
116+
private _lastPosition: Position | undefined;
115117
private readonly _exchange: SessionExchange[] = [];
116118
private readonly _startTime = new Date();
117119
private readonly _teldata: Partial<TelemetryData>;
@@ -155,6 +157,14 @@ export class Session {
155157
return this._lastInput;
156158
}
157159

160+
get lastPosition() {
161+
return this._lastPosition;
162+
}
163+
164+
set lastPosition(position: Position | undefined) {
165+
this._lastPosition = position;
166+
}
167+
158168
get lastExpansionState(): ExpansionState | undefined {
159169
return this._lastExpansionState;
160170
}

0 commit comments

Comments
 (0)