From c2743058a79e8e998b9e9a9e2fa4c79f53e52af3 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 4 Jul 2023 22:39:52 -0700 Subject: side-by-side diff editor --- extension/src/commands.ts | 4 ++ extension/src/continueIdeClient.ts | 38 ++---------- extension/src/diffs.ts | 114 ++++++++++++++++++++++++++++++++++ extension/src/lang-server/codeLens.ts | 40 +++++++++++- 4 files changed, 162 insertions(+), 34 deletions(-) create mode 100644 extension/src/diffs.ts (limited to 'extension/src') diff --git a/extension/src/commands.ts b/extension/src/commands.ts index 8072353b..4414a171 100644 --- a/extension/src/commands.ts +++ b/extension/src/commands.ts @@ -12,6 +12,8 @@ import { acceptAllSuggestionsCommand, rejectAllSuggestionsCommand, } from "./suggestions"; + +import { acceptDiffCommand, rejectDiffCommand } from "./diffs"; import * as bridge from "./bridge"; import { debugPanelWebview } from "./debugPanel"; import { sendTelemetryEvent, TelemetryEvent } from "./telemetry"; @@ -51,6 +53,8 @@ const commandsMap: { [command: string]: (...args: any) => any } = { "continue.suggestionUp": suggestionUpCommand, "continue.acceptSuggestion": acceptSuggestionCommand, "continue.rejectSuggestion": rejectSuggestionCommand, + "continue.acceptDiff": acceptDiffCommand, + "continue.rejectDiff": rejectDiffCommand, "continue.acceptAllSuggestions": acceptAllSuggestionsCommand, "continue.rejectAllSuggestions": rejectAllSuggestionsCommand, "continue.focusContinueInput": async () => { diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index b9969858..90547edc 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -15,6 +15,10 @@ import { import { FileEditWithFullContents } from "../schema/FileEditWithFullContents"; import fs = require("fs"); import { WebsocketMessenger } from "./util/messenger"; +import * as path from "path"; +import * as os from "os"; +import { diffManager } from "./diffs"; + class IdeProtocolClient { private messenger: WebsocketMessenger | null = null; private readonly context: vscode.ExtensionContext; @@ -239,40 +243,8 @@ class IdeProtocolClient { ); } - contentProvider: vscode.Disposable | null = null; - showDiff(filepath: string, replacement: string) { - const myProvider = new (class - implements vscode.TextDocumentContentProvider - { - onDidChangeEmitter = new vscode.EventEmitter(); - onDidChange = this.onDidChangeEmitter.event; - provideTextDocumentContent = (uri: vscode.Uri) => { - return replacement; - }; - })(); - this.contentProvider = vscode.workspace.registerTextDocumentContentProvider( - "continueDiff", - myProvider - ); - - // Call the event fire - const diffFilename = `continueDiff://${filepath}`; - myProvider.onDidChangeEmitter.fire(vscode.Uri.parse(diffFilename)); - - const leftUri = vscode.Uri.file(filepath); - const rightUri = vscode.Uri.parse(diffFilename); - const title = "Continue Diff"; - vscode.commands - .executeCommand("vscode.diff", leftUri, rightUri, title) - .then( - () => { - console.log("Diff view opened successfully"); - }, - (error) => { - console.error("Error opening diff view:", error); - } - ); + diffManager.writeDiff(filepath, replacement); } openFile(filepath: string) { diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts new file mode 100644 index 00000000..4bd072cf --- /dev/null +++ b/extension/src/diffs.ts @@ -0,0 +1,114 @@ +import * as os from "os"; +import * as path from "path"; +import * as fs from "fs"; +import * as vscode from "vscode"; + +interface DiffInfo { + originalFilepath: string; + newFilepath: string; + editor?: vscode.TextEditor; +} + +export const DIFF_DIRECTORY = path.join(os.homedir(), ".continue", "diffs"); + +class DiffManager { + // Create a temporary file in the global .continue directory which displays the updated version + // Doing this because virtual files are read-only + private diffs: Map = new Map(); + + constructor() { + // Make sure the diff directory exists + if (!fs.existsSync(DIFF_DIRECTORY)) { + fs.mkdirSync(DIFF_DIRECTORY, { + recursive: true, + }); + } + } + + private escapeFilepath(filepath: string): string { + return filepath.replace(/\\/g, "_").replace(/\//g, "_"); + } + + private openDiffEditor( + originalFilepath: string, + newFilepath: string, + newContent: string + ): vscode.TextEditor { + const rightUri = vscode.Uri.parse(newFilepath); + const leftUri = vscode.Uri.file(originalFilepath); + const title = "Continue Diff"; + vscode.commands.executeCommand("vscode.diff", leftUri, rightUri, title); + + const editor = vscode.window.activeTextEditor; + if (!editor) { + throw new Error("No active text editor found for Continue Diff"); + } + return editor; + } + + writeDiff(originalFilepath: string, newContent: string): string { + // Create or update existing diff + const newFilepath = path.join( + DIFF_DIRECTORY, + this.escapeFilepath(originalFilepath) + ); + fs.writeFileSync(newFilepath, newContent); + + // Open the diff editor if this is a new diff + if (!this.diffs.has(originalFilepath)) { + const diffInfo: DiffInfo = { + originalFilepath, + newFilepath, + }; + diffInfo.editor = this.openDiffEditor( + originalFilepath, + newFilepath, + newContent + ); + this.diffs.set(originalFilepath, diffInfo); + } + return newFilepath; + } + + cleanUpDiff(diffInfo: DiffInfo) { + // Close the editor, remove the record, delete the file + if (diffInfo.editor) { + vscode.window.showTextDocument(diffInfo.editor.document); + vscode.commands.executeCommand("workbench.action.closeActiveEditor"); + } + this.diffs.delete(diffInfo.originalFilepath); + fs.unlinkSync(diffInfo.newFilepath); + } + + acceptDiff(originalFilepath: string) { + // Get the diff info, copy new file to original, then delete from record and close the corresponding editor + const diffInfo = this.diffs.get(originalFilepath); + if (!diffInfo) { + return; + } + fs.writeFileSync( + diffInfo.originalFilepath, + fs.readFileSync(diffInfo.newFilepath) + ); + this.cleanUpDiff(diffInfo); + } + + rejectDiff(originalFilepath: string) { + const diffInfo = this.diffs.get(originalFilepath); + if (!diffInfo) { + return; + } + + this.cleanUpDiff(diffInfo); + } +} + +export const diffManager = new DiffManager(); + +export async function acceptDiffCommand(originalFilepath: string) { + diffManager.acceptDiff(originalFilepath); +} + +export async function rejectDiffCommand(originalFilepath: string) { + diffManager.rejectDiff(originalFilepath); +} diff --git a/extension/src/lang-server/codeLens.ts b/extension/src/lang-server/codeLens.ts index 3bd4f153..08435a3b 100644 --- a/extension/src/lang-server/codeLens.ts +++ b/extension/src/lang-server/codeLens.ts @@ -1,6 +1,8 @@ import * as vscode from "vscode"; import { editorToSuggestions, editorSuggestionsLocked } from "../suggestions"; - +import * as path from "path"; +import * as os from "os"; +import { DIFF_DIRECTORY } from "../diffs"; class SuggestionsCodeLensProvider implements vscode.CodeLensProvider { public provideCodeLenses( document: vscode.TextDocument, @@ -60,15 +62,51 @@ class SuggestionsCodeLensProvider implements vscode.CodeLensProvider { } } +class DiffViewerCodeLensProvider implements vscode.CodeLensProvider { + public provideCodeLenses( + document: vscode.TextDocument, + token: vscode.CancellationToken + ): vscode.CodeLens[] | Thenable { + if (path.dirname(document.uri.fsPath) !== DIFF_DIRECTORY) { + return []; + } else { + const codeLenses: vscode.CodeLens[] = []; + const range = new vscode.Range(0, 0, 0, 0); + codeLenses.push( + new vscode.CodeLens(range, { + title: "Accept ✅", + command: "continue.acceptDiff", + arguments: [document.uri.fsPath], + }), + new vscode.CodeLens(range, { + title: "Reject ❌", + command: "continue.rejectDiff", + arguments: [document.uri.fsPath], + }) + ); + return codeLenses; + } + } +} + +let diffsCodeLensDisposable: vscode.Disposable | undefined = undefined; let suggestionsCodeLensDisposable: vscode.Disposable | undefined = undefined; export function registerAllCodeLensProviders(context: vscode.ExtensionContext) { if (suggestionsCodeLensDisposable) { suggestionsCodeLensDisposable.dispose(); } + if (diffsCodeLensDisposable) { + diffsCodeLensDisposable.dispose(); + } suggestionsCodeLensDisposable = vscode.languages.registerCodeLensProvider( "*", new SuggestionsCodeLensProvider() ); + diffsCodeLensDisposable = vscode.languages.registerCodeLensProvider( + "*", + new DiffViewerCodeLensProvider() + ); context.subscriptions.push(suggestionsCodeLensDisposable); + context.subscriptions.push(diffsCodeLensDisposable); } -- cgit v1.2.3-70-g09d2 From bf34e1d6a01214a6977a2932b4ee2b413d524957 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 4 Jul 2023 22:55:53 -0700 Subject: small fixes to side-by-side diff --- extension/src/diffs.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'extension/src') diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index 4bd072cf..19ec80ab 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -55,7 +55,7 @@ class DiffManager { fs.writeFileSync(newFilepath, newContent); // Open the diff editor if this is a new diff - if (!this.diffs.has(originalFilepath)) { + if (!this.diffs.has(newFilepath)) { const diffInfo: DiffInfo = { originalFilepath, newFilepath, @@ -65,7 +65,7 @@ class DiffManager { newFilepath, newContent ); - this.diffs.set(originalFilepath, diffInfo); + this.diffs.set(newFilepath, diffInfo); } return newFilepath; } @@ -76,13 +76,13 @@ class DiffManager { vscode.window.showTextDocument(diffInfo.editor.document); vscode.commands.executeCommand("workbench.action.closeActiveEditor"); } - this.diffs.delete(diffInfo.originalFilepath); + this.diffs.delete(diffInfo.newFilepath); fs.unlinkSync(diffInfo.newFilepath); } - acceptDiff(originalFilepath: string) { + acceptDiff(newFilepath: string) { // Get the diff info, copy new file to original, then delete from record and close the corresponding editor - const diffInfo = this.diffs.get(originalFilepath); + const diffInfo = this.diffs.get(newFilepath); if (!diffInfo) { return; } @@ -93,8 +93,8 @@ class DiffManager { this.cleanUpDiff(diffInfo); } - rejectDiff(originalFilepath: string) { - const diffInfo = this.diffs.get(originalFilepath); + rejectDiff(newFilepath: string) { + const diffInfo = this.diffs.get(newFilepath); if (!diffInfo) { return; } @@ -105,10 +105,10 @@ class DiffManager { export const diffManager = new DiffManager(); -export async function acceptDiffCommand(originalFilepath: string) { - diffManager.acceptDiff(originalFilepath); +export async function acceptDiffCommand(newFilepath: string) { + diffManager.acceptDiff(newFilepath); } -export async function rejectDiffCommand(originalFilepath: string) { - diffManager.rejectDiff(originalFilepath); +export async function rejectDiffCommand(newFilepath: string) { + diffManager.rejectDiff(newFilepath); } -- cgit v1.2.3-70-g09d2 From 68831f3d0af34a6f83b120ade86a1aa69a7017ac Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 5 Jul 2023 12:09:10 -0700 Subject: explain by default --- continuedev/src/continuedev/core/config.py | 12 ++++++------ continuedev/src/continuedev/core/policy.py | 6 +++--- extension/package-lock.json | 4 ++-- extension/package.json | 2 +- extension/react-app/src/components/ComboBox.tsx | 5 +++++ extension/src/diffs.ts | 8 +++++++- 6 files changed, 24 insertions(+), 13 deletions(-) (limited to 'extension/src') diff --git a/continuedev/src/continuedev/core/config.py b/continuedev/src/continuedev/core/config.py index 8f7e0b8c..ff7b8cb0 100644 --- a/continuedev/src/continuedev/core/config.py +++ b/continuedev/src/continuedev/core/config.py @@ -33,11 +33,11 @@ DEFAULT_SLASH_COMMANDS = [ description="Edit code in the current file or the highlighted code", step_name="EditHighlightedCodeStep", ), - SlashCommand( - name="explain", - description="Reply to instructions or a question with previous steps and the highlighted code or current file as context", - step_name="SimpleChatStep", - ), + # SlashCommand( + # name="explain", + # description="Reply to instructions or a question with previous steps and the highlighted code or current file as context", + # step_name="SimpleChatStep", + # ), SlashCommand( name="config", description="Open the config file to create new and edit existing slash commands", @@ -129,7 +129,7 @@ def load_global_config() -> ContinueConfig: config_path = os.path.join(global_dir, 'config.json') if not os.path.exists(config_path): with open(config_path, 'w') as f: - json.dump(dict(ContinueConfig()), f) + json.dump(ContinueConfig().dict(), f) with open(config_path, 'r') as f: try: config_dict = json.load(f) diff --git a/continuedev/src/continuedev/core/policy.py b/continuedev/src/continuedev/core/policy.py index ef753ee4..fc9266ab 100644 --- a/continuedev/src/continuedev/core/policy.py +++ b/continuedev/src/continuedev/core/policy.py @@ -74,14 +74,14 @@ class DemoPolicy(Policy): # This could be defined with ObservationTypePolicy. Ergonomics not right though. user_input = observation.user_input - slash_command = parse_slash_command(user_input) + slash_command = parse_slash_command(user_input, config) if slash_command is not None: return slash_command - custom_command = parse_custom_command(user_input) + custom_command = parse_custom_command(user_input, config) if custom_command is not None: return custom_command - return ChatWithFunctions(user_input=user_input) + return SimpleChatStep(user_input=user_input) return None diff --git a/extension/package-lock.json b/extension/package-lock.json index ce1a42ee..169b13b5 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.0.110", + "version": "0.0.111", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.0.110", + "version": "0.0.111", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extension/package.json b/extension/package.json index 607c2ca6..6a0f9eb3 100644 --- a/extension/package.json +++ b/extension/package.json @@ -14,7 +14,7 @@ "displayName": "Continue", "pricing": "Free", "description": "The open-source coding autopilot", - "version": "0.0.110", + "version": "0.0.111", "publisher": "Continue", "engines": { "vscode": "^1.67.0" diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index 73b7cc2d..545be32a 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -195,6 +195,11 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { ) { // Prevent Downshift's default 'Enter' behavior. (event.nativeEvent as any).preventDownshiftDefault = true; + + // cmd+enter to /edit + if (event.metaKey) { + event.currentTarget.value = `/edit ${event.currentTarget}`; + } if (props.onEnter) props.onEnter(event); setInputValue(""); const value = event.currentTarget.value; diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index 19ec80ab..b70c3b59 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -16,7 +16,7 @@ class DiffManager { // Doing this because virtual files are read-only private diffs: Map = new Map(); - constructor() { + private setupDirectory() { // Make sure the diff directory exists if (!fs.existsSync(DIFF_DIRECTORY)) { fs.mkdirSync(DIFF_DIRECTORY, { @@ -25,6 +25,10 @@ class DiffManager { } } + constructor() { + this.setupDirectory(); + } + private escapeFilepath(filepath: string): string { return filepath.replace(/\\/g, "_").replace(/\//g, "_"); } @@ -47,6 +51,8 @@ class DiffManager { } writeDiff(originalFilepath: string, newContent: string): string { + this.setupDirectory(); + // Create or update existing diff const newFilepath = path.join( DIFF_DIRECTORY, -- cgit v1.2.3-70-g09d2 From 8a5cda89378640cef375689d6be48f9ab21cab7e Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 5 Jul 2023 16:28:58 -0700 Subject: setting to show codelens in diff editor --- extension/package-lock.json | 4 ++-- extension/package.json | 3 ++- extension/react-app/src/components/ComboBox.tsx | 2 +- extension/react-app/src/main.tsx | 4 ++++ extension/src/diffs.ts | 6 ++++++ extension/src/lang-server/codeLens.ts | 24 ++++++++++++++++++++---- 6 files changed, 35 insertions(+), 8 deletions(-) (limited to 'extension/src') diff --git a/extension/package-lock.json b/extension/package-lock.json index 169b13b5..6e527583 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.0.111", + "version": "0.0.112", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.0.111", + "version": "0.0.112", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extension/package.json b/extension/package.json index 6a0f9eb3..413e5b89 100644 --- a/extension/package.json +++ b/extension/package.json @@ -14,7 +14,7 @@ "displayName": "Continue", "pricing": "Free", "description": "The open-source coding autopilot", - "version": "0.0.111", + "version": "0.0.112", "publisher": "Continue", "engines": { "vscode": "^1.67.0" @@ -39,6 +39,7 @@ "onView:continueGUIView" ], "main": "./out/extension.js", + "browser": "./out/extension.js", "contributes": { "configuration": { "title": "Continue", diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index 545be32a..61c9ab1e 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -198,7 +198,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { // cmd+enter to /edit if (event.metaKey) { - event.currentTarget.value = `/edit ${event.currentTarget}`; + event.currentTarget.value = `/edit ${event.currentTarget.value}`; } if (props.onEnter) props.onEnter(event); setInputValue(""); diff --git a/extension/react-app/src/main.tsx b/extension/react-app/src/main.tsx index 1b94dc82..0b02575c 100644 --- a/extension/react-app/src/main.tsx +++ b/extension/react-app/src/main.tsx @@ -8,6 +8,10 @@ import { PostHogProvider } from "posthog-js/react"; posthog.init("phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs", { api_host: "https://app.posthog.com", + session_recording: { + // WARNING: Only enable this if you understand the security implications + recordCrossOriginIframes: true, + } as any, }); ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index b70c3b59..178b1a9d 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -47,6 +47,12 @@ class DiffManager { if (!editor) { throw new Error("No active text editor found for Continue Diff"); } + + // Change the vscode setting to allow codeLens in diff editor + vscode.workspace + .getConfiguration("diffEditor", editor.document.uri) + .update("codeLens", true, vscode.ConfigurationTarget.Global); + return editor; } diff --git a/extension/src/lang-server/codeLens.ts b/extension/src/lang-server/codeLens.ts index 08435a3b..381a0084 100644 --- a/extension/src/lang-server/codeLens.ts +++ b/extension/src/lang-server/codeLens.ts @@ -67,11 +67,9 @@ class DiffViewerCodeLensProvider implements vscode.CodeLensProvider { document: vscode.TextDocument, token: vscode.CancellationToken ): vscode.CodeLens[] | Thenable { - if (path.dirname(document.uri.fsPath) !== DIFF_DIRECTORY) { - return []; - } else { + if (path.dirname(document.uri.fsPath) === DIFF_DIRECTORY) { const codeLenses: vscode.CodeLens[] = []; - const range = new vscode.Range(0, 0, 0, 0); + const range = new vscode.Range(0, 0, 1, 0); codeLenses.push( new vscode.CodeLens(range, { title: "Accept ✅", @@ -85,6 +83,24 @@ class DiffViewerCodeLensProvider implements vscode.CodeLensProvider { }) ); return codeLenses; + } else { + return []; + } + } + + onDidChangeCodeLenses?: vscode.Event | undefined; + + constructor(emitter?: vscode.EventEmitter) { + if (emitter) { + this.onDidChangeCodeLenses = emitter.event; + this.onDidChangeCodeLenses(() => { + if (vscode.window.activeTextEditor) { + this.provideCodeLenses( + vscode.window.activeTextEditor.document, + new vscode.CancellationTokenSource().token + ); + } + }); } } } -- cgit v1.2.3-70-g09d2 From 22b02641b4b14ffad32914d046e645cf6f850253 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 5 Jul 2023 20:35:59 -0700 Subject: stuff --- continuedev/src/continuedev/core/autopilot.py | 4 ++++ continuedev/src/continuedev/steps/core/core.py | 19 +++++++++++-------- extension/package-lock.json | 4 ++-- extension/package.json | 6 +++--- extension/react-app/src/components/ComboBox.tsx | 2 +- extension/src/diffs.ts | 22 ++++++++++++++++++---- 6 files changed, 39 insertions(+), 18 deletions(-) (limited to 'extension/src') diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py index 29be3b79..b1c4f471 100644 --- a/continuedev/src/continuedev/core/autopilot.py +++ b/continuedev/src/continuedev/core/autopilot.py @@ -147,6 +147,10 @@ class Autopilot(ContinueBaseModel): if not self._adding_highlighted_code: return + # Filter out rifs from ~/.continue/diffs folder + range_in_files = [ + rif for rif in range_in_files if not os.path.dirname(rif.filepath) == os.path.expanduser("~/.continue/diffs")] + workspace_path = self.continue_sdk.ide.workspace_directory for rif in range_in_files: rif.filepath = os.path.basename(rif.filepath) diff --git a/continuedev/src/continuedev/steps/core/core.py b/continuedev/src/continuedev/steps/core/core.py index c74412ba..3a7c8876 100644 --- a/continuedev/src/continuedev/steps/core/core.py +++ b/continuedev/src/continuedev/steps/core/core.py @@ -332,8 +332,9 @@ class DefaultModelEditCodeStep(Step): # Highlight the line to show progress line_to_highlight = current_line_in_file - len(current_block_lines) - await sdk.ide.highlightCode(RangeInFile(filepath=rif.filepath, range=Range.from_shorthand( - line_to_highlight, 0, line_to_highlight, 0)), "#FFFFFF22" if len(current_block_lines) == 0 else "#00FF0022") + if False: + await sdk.ide.highlightCode(RangeInFile(filepath=rif.filepath, range=Range.from_shorthand( + line_to_highlight, 0, line_to_highlight, 0)), "#FFFFFF22" if len(current_block_lines) == 0 else "#00FF0022") if len(current_block_lines) == 0: # Set this as the start of the next block @@ -382,12 +383,14 @@ class DefaultModelEditCodeStep(Step): replacement = "\n".join(current_block_lines) start_line = current_block_start end_line = current_block_start + index_of_last_line_in_block - await sdk.ide.showSuggestion(FileEdit( - filepath=rif.filepath, - range=Range.from_shorthand( - start_line, 0, end_line, 0), - replacement=replacement - )) + + if False: + await sdk.ide.showSuggestion(FileEdit( + filepath=rif.filepath, + range=Range.from_shorthand( + start_line, 0, end_line, 0), + replacement=replacement + )) # Reset current block / update variables current_line_in_file += 1 diff --git a/extension/package-lock.json b/extension/package-lock.json index 6e527583..b322acb7 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.0.112", + "version": "0.0.113", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "continue", - "version": "0.0.112", + "version": "0.0.113", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extension/package.json b/extension/package.json index 413e5b89..09703da4 100644 --- a/extension/package.json +++ b/extension/package.json @@ -14,7 +14,7 @@ "displayName": "Continue", "pricing": "Free", "description": "The open-source coding autopilot", - "version": "0.0.112", + "version": "0.0.113", "publisher": "Continue", "engines": { "vscode": "^1.67.0" @@ -130,12 +130,12 @@ "key": "shift+ctrl+enter" }, { - "command": "continue.acceptAllSuggestions", + "command": "continue.acceptDiff", "mac": "shift+cmd+enter", "key": "shift+ctrl+enter" }, { - "command": "continue.rejectAllSuggestions", + "command": "continue.rejectDiff", "mac": "shift+cmd+backspace", "key": "shift+ctrl+backspace" } diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index 61c9ab1e..81b148b9 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -55,7 +55,7 @@ const MainTextInput = styled.textarea` } `; -const UlMaxHeight = 200; +const UlMaxHeight = 400; const Ul = styled.ul<{ hidden: boolean; showAbove: boolean; diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index 178b1a9d..1b8888e8 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -92,7 +92,14 @@ class DiffManager { fs.unlinkSync(diffInfo.newFilepath); } - acceptDiff(newFilepath: string) { + acceptDiff(newFilepath?: string) { + // If no newFilepath is provided and there is only one in the dictionary, use that + if (!newFilepath && this.diffs.size === 1) { + newFilepath = Array.from(this.diffs.keys())[0]; + } + if (!newFilepath) { + return; + } // Get the diff info, copy new file to original, then delete from record and close the corresponding editor const diffInfo = this.diffs.get(newFilepath); if (!diffInfo) { @@ -105,7 +112,14 @@ class DiffManager { this.cleanUpDiff(diffInfo); } - rejectDiff(newFilepath: string) { + rejectDiff(newFilepath?: string) { + // If no newFilepath is provided and there is only one in the dictionary, use that + if (!newFilepath && this.diffs.size === 1) { + newFilepath = Array.from(this.diffs.keys())[0]; + } + if (!newFilepath) { + return; + } const diffInfo = this.diffs.get(newFilepath); if (!diffInfo) { return; @@ -117,10 +131,10 @@ class DiffManager { export const diffManager = new DiffManager(); -export async function acceptDiffCommand(newFilepath: string) { +export async function acceptDiffCommand(newFilepath?: string) { diffManager.acceptDiff(newFilepath); } -export async function rejectDiffCommand(newFilepath: string) { +export async function rejectDiffCommand(newFilepath?: string) { diffManager.rejectDiff(newFilepath); } -- cgit v1.2.3-70-g09d2