diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index b87ee410a..125bf065d 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -446,4 +446,9 @@ export class VerticalDiffHandler implements vscode.Disposable { //update code lens this.shiftCodeLensObjects(startLine, lineDelta); } + + public hasDiffForCurrentFile(): boolean { + const diffBlocks = this.editorToVerticalDiffCodeLens.get(this.filepath); + return diffBlocks !== undefined && diffBlocks.length > 0; + } } diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts index 24fe04227..bc59a175c 100644 --- a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -134,7 +134,6 @@ export class QuickEdit { */ async show(args?: QuickEditShowParams) { // Clean up state from previous quick picks, e.g. if a user pressed `esc` - this.clear(); const editor = vscode.window.activeTextEditor; @@ -143,6 +142,17 @@ export class QuickEdit { return; } + const hasChanges = await this.verticalDiffManager.getHandlerForFile( + editor.document.uri.fsPath, + ); + + if (!hasChanges) { + this.clear(); + } else { + this.openAcceptRejectMenu("", editor.document.uri.fsPath); + return; + } + // Set state that is unique to each quick pick instance this.setActiveEditorAndPrevInput(editor); @@ -224,13 +234,7 @@ export class QuickEdit { } } - private handleUserPrompt = async ( - prompt: string, - path: string | undefined, - ) => { - const modelTitle = await this.getCurModelTitle(); - await this._streamEditWithInputAndContext(prompt, modelTitle); - + private openAcceptRejectMenu(prompt: string, path: string | undefined) { const quickPick = vscode.window.createQuickPick(); quickPick.placeholder = "Type your acceptance decision"; @@ -270,6 +274,15 @@ export class QuickEdit { quickPick.dispose(); }); + } + + private handleUserPrompt = async ( + prompt: string, + path: string | undefined, + ) => { + const modelTitle = await this.getCurModelTitle(); + await this._streamEditWithInputAndContext(prompt, modelTitle); + this.openAcceptRejectMenu(prompt, path); }; private async initializeFileSearchState() {