summaryrefslogtreecommitdiff
path: root/extension/src/commands.ts
diff options
context:
space:
mode:
Diffstat (limited to 'extension/src/commands.ts')
-rw-r--r--extension/src/commands.ts117
1 files changed, 22 insertions, 95 deletions
diff --git a/extension/src/commands.ts b/extension/src/commands.ts
index ffb67ab5..2b7f4c0c 100644
--- a/extension/src/commands.ts
+++ b/extension/src/commands.ts
@@ -16,40 +16,16 @@ import {
import { acceptDiffCommand, rejectDiffCommand } from "./diffs";
import * as bridge from "./bridge";
import { debugPanelWebview } from "./debugPanel";
-import { sendTelemetryEvent, TelemetryEvent } from "./telemetry";
import { ideProtocolClient } from "./activation/activate";
-// Copy everything over from extension.ts
-const commandsMap: { [command: string]: (...args: any) => any } = {
- "continue.askQuestion": (data: any, webviewView: vscode.WebviewView) => {
- if (!vscode.workspace.workspaceFolders) {
- return;
- }
-
- answerQuestion(
- data.question,
- vscode.workspace.workspaceFolders[0].uri.fsPath,
- webviewView.webview
- );
- },
- "continue.askQuestionFromInput": () => {
- vscode.window
- .showInputBox({ placeHolder: "Ask away!" })
- .then((question) => {
- if (!question || !vscode.workspace.workspaceFolders) {
- return;
- }
+let focusedOnContinueInput = false;
- sendTelemetryEvent(TelemetryEvent.UniversalPromptQuery, {
- query: question,
- });
+export const setFocusedOnContinueInput = (value: boolean) => {
+ focusedOnContinueInput = value;
+};
- answerQuestion(
- question,
- vscode.workspace.workspaceFolders[0].uri.fsPath
- );
- });
- },
+// Copy everything over from extension.ts
+const commandsMap: { [command: string]: (...args: any) => any } = {
"continue.suggestionDown": suggestionDownCommand,
"continue.suggestionUp": suggestionUpCommand,
"continue.acceptSuggestion": acceptSuggestionCommand,
@@ -58,11 +34,23 @@ const commandsMap: { [command: string]: (...args: any) => any } = {
"continue.rejectDiff": rejectDiffCommand,
"continue.acceptAllSuggestions": acceptAllSuggestionsCommand,
"continue.rejectAllSuggestions": rejectAllSuggestionsCommand,
+ "continue.quickFix": async (message: string, code: string, edit: boolean) => {
+ ideProtocolClient.sendMainUserInput(
+ `${
+ edit ? "/edit " : ""
+ }${code}\n\nHow do I fix this problem in the above code?: ${message}`
+ );
+ },
"continue.focusContinueInput": async () => {
- vscode.commands.executeCommand("continue.continueGUIView.focus");
- debugPanelWebview?.postMessage({
- type: "focusContinueInput",
- });
+ if (focusedOnContinueInput) {
+ vscode.commands.executeCommand("workbench.action.focusActiveEditorGroup");
+ } else {
+ vscode.commands.executeCommand("continue.continueGUIView.focus");
+ debugPanelWebview?.postMessage({
+ type: "focusContinueInput",
+ });
+ }
+ focusedOnContinueInput = !focusedOnContinueInput;
},
"continue.quickTextEntry": async () => {
const text = await vscode.window.showInputBox({
@@ -73,27 +61,6 @@ const commandsMap: { [command: string]: (...args: any) => any } = {
if (text) {
ideProtocolClient.sendMainUserInput(text);
}
- vscode.commands.executeCommand("continue.continueGUIView.focus");
- },
-};
-
-const textEditorCommandsMap: { [command: string]: (...args: any) => {} } = {
- "continue.writeDocstring": async (editor: vscode.TextEditor, _) => {
- sendTelemetryEvent(TelemetryEvent.GenerateDocstring);
- let gutterSpinnerKey = showGutterSpinner(
- editor,
- editor.selection.active.line
- );
-
- const { lineno, docstring } = await bridge.writeDocstringForFunction(
- editor.document.fileName,
- editor.selection.active
- );
- // Can't use the edit given above after an async call
- editor.edit((edit) => {
- edit.insert(new vscode.Position(lineno, 0), docstring);
- decorationManager.deleteDecoration(gutterSpinnerKey);
- });
},
};
@@ -103,44 +70,4 @@ export function registerAllCommands(context: vscode.ExtensionContext) {
vscode.commands.registerCommand(command, callback)
);
}
-
- for (const [command, callback] of Object.entries(textEditorCommandsMap)) {
- context.subscriptions.push(
- vscode.commands.registerTextEditorCommand(command, callback)
- );
- }
-}
-
-async function answerQuestion(
- question: string,
- workspacePath: string,
- webview: vscode.Webview | undefined = undefined
-) {
- vscode.window.withProgress(
- {
- location: vscode.ProgressLocation.Notification,
- title: "Anwering question...",
- cancellable: false,
- },
- async (progress, token) => {
- try {
- let resp = await bridge.askQuestion(question, workspacePath);
- // Send the answer back to the webview
- if (webview) {
- webview.postMessage({
- type: "answerQuestion",
- answer: resp.answer,
- });
- }
- showAnswerInTextEditor(resp.filename, resp.range, resp.answer);
- } catch (error: any) {
- if (webview) {
- webview.postMessage({
- type: "answerQuestion",
- answer: error,
- });
- }
- }
- }
- );
}