Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix https://github.com/microsoft/vscode-copilot/issues/3134 #199523

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ export class InlineChatController implements IEditorContribution {
this._zone.value.widget.updateFollowUps(undefined);
this._zone.value.widget.updateProgress(true);
this._zone.value.widget.updateInfo(!this._activeSession.lastExchange ? localize('thinking', "Thinking\u2026") : '');
await this._strategy.start();
this._ctxHasActiveRequest.set(true);
reply = await raceCancellationError(Promise.resolve(task), requestCts.token);

Expand Down
33 changes: 22 additions & 11 deletions src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export abstract class EditModeStrategy {
this._onDidDiscard.dispose();
}

abstract start(): Promise<void>;

abstract apply(): Promise<void>;

abstract cancel(): Promise<void>;
Expand Down Expand Up @@ -102,6 +104,10 @@ export class PreviewStrategy extends EditModeStrategy {
super.dispose();
}

async start() {
// nothing to do
}

async apply() {

if (!(this._session.lastExchange?.response instanceof ReplyResponse)) {
Expand Down Expand Up @@ -280,6 +286,10 @@ export class LiveStrategy extends EditModeStrategy {
this._inlineDiffDecorations.visible = this._diffEnabled;
}

async start() {
// nothing to do
}

async apply() {
if (this._editCount > 0) {
this._editor.pushUndoStop();
Expand Down Expand Up @@ -637,22 +647,27 @@ export class LiveStrategy3 extends EditModeStrategy {
}

override dispose(): void {
this._ctxCurrentChangeHasDiff.reset();
this._ctxCurrentChangeShowsDiff.reset();
this._modifiedRangesDecorations.clear();
this._resetDiff();
this._previewZone.rawValue?.dispose();
this._sessionStore.dispose();
this._store.dispose();
super.dispose();
}


async apply() {
private _resetDiff(): void {
this._ctxCurrentChangeHasDiff.reset();
this._ctxCurrentChangeShowsDiff.reset();
this._sessionStore.clear();
this._modifiedRangesDecorations.clear();
this._modifiedRangesThatHaveBeenInteractedWith.length = 0;
this._zone.widget.updateStatus('');
}

async start() {
this._resetDiff();
}

async apply() {
this._resetDiff();
if (this._editCount > 0) {
this._editor.pushUndoStop();
}
Expand All @@ -666,11 +681,7 @@ export class LiveStrategy3 extends EditModeStrategy {
}

async cancel() {
this._ctxCurrentChangeHasDiff.reset();
this._ctxCurrentChangeShowsDiff.reset();
this._sessionStore.clear();
this._modifiedRangesDecorations.clear();
this._modifiedRangesThatHaveBeenInteractedWith.length = 0;
this._resetDiff();
const { textModelN: modelN, textModelNAltVersion, textModelNSnapshotAltVersion } = this._session;
if (modelN.isDisposed()) {
return;
Expand Down