summaryrefslogtreecommitdiff
path: root/extension
diff options
context:
space:
mode:
Diffstat (limited to 'extension')
-rw-r--r--extension/src/continueIdeClient.ts9
-rw-r--r--extension/src/debugPanel.ts18
-rw-r--r--extension/src/lang-server/codeLens.ts7
-rw-r--r--extension/src/suggestions.ts1
4 files changed, 27 insertions, 8 deletions
diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts
index 2e641054..1ccc070c 100644
--- a/extension/src/continueIdeClient.ts
+++ b/extension/src/continueIdeClient.ts
@@ -1,5 +1,6 @@
// import { ShowSuggestionRequest } from "../schema/ShowSuggestionRequest";
import {
+ editorSuggestionsLocked,
showSuggestion as showSuggestionInEditor,
SuggestionRanges,
} from "./suggestions";
@@ -119,6 +120,9 @@ class IdeProtocolClient {
this.openFile(data.filepath);
// TODO: Close file if False
break;
+ case "setSuggestionsLocked":
+ this.setSuggestionsLocked(data.filepath, data.locked);
+ break;
case "showSuggestion":
this.showSuggestion(data.edit);
break;
@@ -204,6 +208,11 @@ class IdeProtocolClient {
openEditorAndRevealRange(filepath, undefined, vscode.ViewColumn.One);
}
+ setSuggestionsLocked(filepath: string, locked: boolean) {
+ editorSuggestionsLocked.set(filepath, locked);
+ // TODO: Rerender?
+ }
+
async getUserSecret(key: string) {
// Check if secret already exists in VS Code settings (global)
let secret = vscode.workspace.getConfiguration("continue").get(key);
diff --git a/extension/src/debugPanel.ts b/extension/src/debugPanel.ts
index 4f3d097c..b176eee7 100644
--- a/extension/src/debugPanel.ts
+++ b/extension/src/debugPanel.ts
@@ -113,7 +113,13 @@ class WebsocketConnection {
if (typeof message !== "string") {
message = JSON.stringify(message);
}
- this._ws.send(message);
+ if (this._ws.readyState === WebSocket.OPEN) {
+ this._ws.send(message);
+ } else {
+ this._ws.addEventListener("open", () => {
+ this._ws.send(message);
+ });
+ }
}
public close() {
@@ -231,7 +237,9 @@ export function setupDebugPanel(
apiUrl: getContinueServerUrl(),
sessionId,
vscMediaUrl,
- dataSwitchOn: vscode.workspace.getConfiguration("continue").get<boolean>("dataSwitch")
+ dataSwitchOn: vscode.workspace
+ .getConfiguration("continue")
+ .get<boolean>("dataSwitch"),
});
// // Listen for changes to server URL in settings
@@ -249,10 +257,10 @@ export function setupDebugPanel(
break;
}
case "toggleDataSwitch": {
- // Set the setting in vscode
+ // Set the setting in vscode
await vscode.workspace
- .getConfiguration("continue")
- .update("dataSwitch", data.on, vscode.ConfigurationTarget.Global);
+ .getConfiguration("continue")
+ .update("dataSwitch", data.on, vscode.ConfigurationTarget.Global);
break;
}
case "websocketForwardingOpen": {
diff --git a/extension/src/lang-server/codeLens.ts b/extension/src/lang-server/codeLens.ts
index 5b55589c..03a9a0a7 100644
--- a/extension/src/lang-server/codeLens.ts
+++ b/extension/src/lang-server/codeLens.ts
@@ -1,5 +1,5 @@
import * as vscode from "vscode";
-import { editorToSuggestions } from "../suggestions";
+import { editorToSuggestions, editorSuggestionsLocked } from "../suggestions";
class SuggestionsCodeLensProvider implements vscode.CodeLensProvider {
public provideCodeLenses(
@@ -10,6 +10,7 @@ class SuggestionsCodeLensProvider implements vscode.CodeLensProvider {
if (!suggestions) {
return [];
}
+ const locked = editorSuggestionsLocked.get(document.uri.fsPath.toString());
const codeLenses: vscode.CodeLens[] = [];
for (const suggestion of suggestions) {
@@ -20,12 +21,12 @@ class SuggestionsCodeLensProvider implements vscode.CodeLensProvider {
codeLenses.push(
new vscode.CodeLens(range, {
title: "Accept ✅",
- command: "continue.acceptSuggestion",
+ command: locked ? "" : "continue.acceptSuggestion",
arguments: [suggestion],
}),
new vscode.CodeLens(range, {
title: "Reject ❌",
- command: "continue.rejectSuggestion",
+ command: locked ? "" : "continue.rejectSuggestion",
arguments: [suggestion],
})
);
diff --git a/extension/src/suggestions.ts b/extension/src/suggestions.ts
index 8bed202c..e269f38a 100644
--- a/extension/src/suggestions.ts
+++ b/extension/src/suggestions.ts
@@ -17,6 +17,7 @@ export const editorToSuggestions: Map<
string, // URI of file
SuggestionRanges[]
> = new Map();
+export const editorSuggestionsLocked: Map<string, boolean> = new Map(); // Map from editor URI to whether the suggestions are locked
export const currentSuggestion: Map<string, number> = new Map(); // Map from editor URI to index of current SuggestionRanges in editorToSuggestions
// When tab is reopened, rerender the decorations: