summaryrefslogtreecommitdiff
path: root/extension/src
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-06-12 10:50:33 -0700
committerNate Sesti <sestinj@gmail.com>2023-06-12 10:50:33 -0700
commit40ba9eaf82a1386ccacf5046c072df3d131d5284 (patch)
treebf2267e7d1abd34b408265bec8c8c189366bec32 /extension/src
parentaf34f8eae701a875a2a85fca29ffc0d88deb1400 (diff)
downloadsncontinue-40ba9eaf82a1386ccacf5046c072df3d131d5284.tar.gz
sncontinue-40ba9eaf82a1386ccacf5046c072df3d131d5284.tar.bz2
sncontinue-40ba9eaf82a1386ccacf5046c072df3d131d5284.zip
calculate diff and highlight changes
Diffstat (limited to 'extension/src')
-rw-r--r--extension/src/continueIdeClient.ts31
-rw-r--r--extension/src/decorations.ts19
2 files changed, 43 insertions, 7 deletions
diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts
index bbaf5f08..c395ae0e 100644
--- a/extension/src/continueIdeClient.ts
+++ b/extension/src/continueIdeClient.ts
@@ -13,6 +13,7 @@ import { FileEditWithFullContents } from "../schema/FileEditWithFullContents";
import fs = require("fs");
import { WebsocketMessenger } from "./util/messenger";
import { CapturedTerminal } from "./terminal/terminalEmulator";
+import { decorationManager } from "./decorations";
class IdeProtocolClient {
private messenger: WebsocketMessenger | null = null;
@@ -281,8 +282,36 @@ class IdeProtocolClient {
edit.range.start.line,
edit.range.start.character,
edit.range.end.line,
- edit.range.end.character + 1
+ edit.range.end.character
);
+ const decorationKey =
+ edit.replacement === ""
+ ? {
+ editorUri: editor.document.uri.fsPath,
+ options: {
+ range: new vscode.Range(
+ new vscode.Position(range.start.line, 0),
+ new vscode.Position(range.end.line + 1, 0)
+ ),
+ // after: {
+ // contentText: "Removed",
+ // },
+ },
+ decorationType: vscode.window.createTextEditorDecorationType({
+ backgroundColor: "rgba(255, 0, 0, 0.2)",
+ }),
+ }
+ : {
+ editorUri: editor.document.uri.fsPath,
+ options: {
+ range,
+ },
+ decorationType: vscode.window.createTextEditorDecorationType({
+ backgroundColor: "rgba(66, 105, 55, 1.0)",
+ isWholeLine: true,
+ }),
+ };
+ decorationManager.addDecoration(decorationKey);
editor.edit((editBuilder) => {
this._makingEdit += 2; // editBuilder.replace takes 2 edits: delete and insert
editBuilder.replace(range, edit.replacement);
diff --git a/extension/src/decorations.ts b/extension/src/decorations.ts
index 456f0c10..d2c94135 100644
--- a/extension/src/decorations.ts
+++ b/extension/src/decorations.ts
@@ -94,15 +94,22 @@ class DecorationManager {
decorationTypes = new Map();
decorationTypes.set(key.decorationType, [key.options]);
this.editorToDecorations.set(key.editorUri, decorationTypes);
- }
-
- const decorations = decorationTypes.get(key.decorationType);
- if (!decorations) {
- decorationTypes.set(key.decorationType, [key.options]);
} else {
- decorations.push(key.options);
+ const decorations = decorationTypes.get(key.decorationType);
+ if (!decorations) {
+ decorationTypes.set(key.decorationType, [key.options]);
+ } else {
+ decorations.push(key.options);
+ }
}
+
this.rerenderDecorations(key.editorUri, key.decorationType);
+
+ vscode.window.onDidChangeTextEditorSelection((event) => {
+ if (event.textEditor.document.fileName === key.editorUri) {
+ this.deleteAllDecorations(key.editorUri);
+ }
+ });
}
deleteDecoration(key: DecorationKey) {