summaryrefslogtreecommitdiff
path: root/extension
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-07-04 11:58:02 -0700
committerNate Sesti <sestinj@gmail.com>2023-07-04 11:58:02 -0700
commit2a524193d26ffca7ef62445f2069773e106f68a8 (patch)
tree79183b04923cb1e2eb361a2053cde1004027b833 /extension
parent77c39db46ca0b66ad601e55f9457d5a78ade8dfc (diff)
downloadsncontinue-2a524193d26ffca7ef62445f2069773e106f68a8.tar.gz
sncontinue-2a524193d26ffca7ef62445f2069773e106f68a8.tar.bz2
sncontinue-2a524193d26ffca7ef62445f2069773e106f68a8.zip
3.8 compatibility and deleting context all at once
Diffstat (limited to 'extension')
-rw-r--r--extension/react-app/src/hooks/ContinueGUIClientProtocol.ts2
-rw-r--r--extension/react-app/src/hooks/useContinueGUIProtocol.ts4
-rw-r--r--extension/react-app/src/tabs/gui.tsx2
-rw-r--r--extension/src/continueIdeClient.ts39
4 files changed, 43 insertions, 4 deletions
diff --git a/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts b/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts
index 228e9a53..96ea7ab3 100644
--- a/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts
+++ b/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts
@@ -21,7 +21,7 @@ abstract class AbstractContinueGUIClientProtocol {
abstract deleteAtIndex(index: number): void;
- abstract deleteContextItemAtIndex(index: number): void;
+ abstract deleteContextAtIndices(indices: number[]): void;
}
export default AbstractContinueGUIClientProtocol;
diff --git a/extension/react-app/src/hooks/useContinueGUIProtocol.ts b/extension/react-app/src/hooks/useContinueGUIProtocol.ts
index a0c38c0f..e950387c 100644
--- a/extension/react-app/src/hooks/useContinueGUIProtocol.ts
+++ b/extension/react-app/src/hooks/useContinueGUIProtocol.ts
@@ -71,8 +71,8 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
this.messenger.send("delete_at_index", { index });
}
- deleteContextItemAtIndex(index: number) {
- this.messenger.send("delete_context_item_at_index", { index });
+ deleteContextAtIndices(indices: number[]) {
+ this.messenger.send("delete_context_at_indices", { indices });
}
}
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index 40256f86..0a9e48fb 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -187,7 +187,7 @@ function GUI(props: GUIProps) {
const deleteContextItem = useCallback(
(idx: number) => {
- client?.deleteContextItemAtIndex(idx);
+ client?.deleteContextAtIndices([idx]);
},
[client]
);
diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts
index 999bca88..c517eb98 100644
--- a/extension/src/continueIdeClient.ts
+++ b/extension/src/continueIdeClient.ts
@@ -159,6 +159,9 @@ class IdeProtocolClient {
case "showSuggestion":
this.showSuggestion(data.edit);
break;
+ case "showDiff":
+ this.showDiff(data.filepath, data.replacement);
+ break;
case "openGUI":
case "connected":
break;
@@ -236,6 +239,42 @@ class IdeProtocolClient {
);
}
+ contentProvider: vscode.Disposable | null = null;
+
+ showDiff(filepath: string, replacement: string) {
+ const myProvider = new (class
+ implements vscode.TextDocumentContentProvider
+ {
+ onDidChangeEmitter = new vscode.EventEmitter<vscode.Uri>();
+ 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);
+ }
+ );
+ }
+
openFile(filepath: string) {
// vscode has a builtin open/get open files
openEditorAndRevealRange(filepath, undefined, vscode.ViewColumn.One);