From bb582f86b0fa4a3b98008b5295883c8b3dd1b20b Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 30 Jan 2024 19:36:37 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20stop=20button=20for=20streaming?= =?UTF-8?q?=20diffs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/package.json | 10 ++++++- extensions/vscode/src/diff/horizontal.ts | 10 +++++-- .../src/diff/verticalPerLine/manager.ts | 28 ++++++++++++++----- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 136baa224..6e4eb007a 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -80,7 +80,8 @@ "command": "continue.rejectDiff", "category": "Continue", "title": "Reject Diff", - "group": "Continue" + "group": "Continue", + "icon": "$(stop)" }, { "command": "continue.quickEdit", @@ -261,6 +262,13 @@ "group": "0_acontinue" } ], + "editor/title/run": [ + { + "command": "continue.rejectDiff", + "group": "Continue", + "when": "continue.streamingDiff" + } + ], "continue.continueSubMenu": [ { "command": "continue.focusContinueInputWithoutClear", diff --git a/extensions/vscode/src/diff/horizontal.ts b/extensions/vscode/src/diff/horizontal.ts index 462778c73..d9c89bdd8 100644 --- a/extensions/vscode/src/diff/horizontal.ts +++ b/extensions/vscode/src/diff/horizontal.ts @@ -342,12 +342,18 @@ async function recordAcceptReject(accepted: boolean, diffInfo: DiffInfo) { ); } -export async function acceptDiffCommand(newFilepath?: string) { +export async function acceptDiffCommand(newFilepath?: string | vscode.Uri) { + if (newFilepath instanceof vscode.Uri) { + newFilepath = newFilepath.fsPath; + } verticalPerLineDiffManager.clearForFilepath(newFilepath, true); await diffManager.acceptDiff(newFilepath); } -export async function rejectDiffCommand(newFilepath?: string) { +export async function rejectDiffCommand(newFilepath?: string | vscode.Uri) { + if (newFilepath instanceof vscode.Uri) { + newFilepath = newFilepath.fsPath; + } verticalPerLineDiffManager.clearForFilepath(newFilepath, false); await diffManager.rejectDiff(newFilepath); } diff --git a/extensions/vscode/src/diff/verticalPerLine/manager.ts b/extensions/vscode/src/diff/verticalPerLine/manager.ts index 12c9cd7cb..a85b58100 100644 --- a/extensions/vscode/src/diff/verticalPerLine/manager.ts +++ b/extensions/vscode/src/diff/verticalPerLine/manager.ts @@ -108,14 +108,28 @@ export async function streamEdit(input: string) { editor.selection.active ); - await diffHandler.run( - streamDiffLines( - rangeContent, - llm, - input, - getMarkdownLanguageTagForFile(filepath) - ) + vscode.commands.executeCommand( + "setContext", + "continue.streamingDiff", + true ); + + try { + await diffHandler.run( + streamDiffLines( + rangeContent, + llm, + input, + getMarkdownLanguageTagForFile(filepath) + ) + ); + } finally { + vscode.commands.executeCommand( + "setContext", + "continue.streamingDiff", + false + ); + } } }