summaryrefslogtreecommitdiff
path: root/extension/src
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-07-01 12:36:57 -0700
committerNate Sesti <sestinj@gmail.com>2023-07-01 12:36:57 -0700
commit36577b8e94809da47a540499132774a0fe2c085d (patch)
treee912172745fedf947b0f393ceaa2d36aaa703626 /extension/src
parent95ce61f2655dcbeb4fed019b6a9d8a632bad7adc (diff)
downloadsncontinue-36577b8e94809da47a540499132774a0fe2c085d.tar.gz
sncontinue-36577b8e94809da47a540499132774a0fe2c085d.tar.bz2
sncontinue-36577b8e94809da47a540499132774a0fe2c085d.zip
explicit context pill buttons
Diffstat (limited to 'extension/src')
-rw-r--r--extension/src/continueIdeClient.ts39
1 files changed, 36 insertions, 3 deletions
diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts
index 21104abe..8f45b849 100644
--- a/extension/src/continueIdeClient.ts
+++ b/extension/src/continueIdeClient.ts
@@ -12,18 +12,17 @@ import {
acceptSuggestionCommand,
rejectSuggestionCommand,
} from "./suggestions";
-import { debugPanelWebview, setupDebugPanel } from "./debugPanel";
import { FileEditWithFullContents } from "../schema/FileEditWithFullContents";
import fs = require("fs");
import { WebsocketMessenger } from "./util/messenger";
-import { decorationManager } from "./decorations";
-
class IdeProtocolClient {
private messenger: WebsocketMessenger | null = null;
private readonly context: vscode.ExtensionContext;
private _makingEdit = 0;
+ private _highlightDebounce: NodeJS.Timeout | null = null;
+
constructor(serverUrl: string, context: vscode.ExtensionContext) {
this.context = context;
@@ -65,6 +64,36 @@ class IdeProtocolClient {
// this._makingEdit--;
// }
// });
+
+ // Setup listeners for any file changes in open editors
+ vscode.window.onDidChangeTextEditorSelection((event) => {
+ if (this._highlightDebounce) {
+ clearTimeout(this._highlightDebounce);
+ }
+ this._highlightDebounce = setTimeout(() => {
+ const highlightedCode = event.textEditor.selections
+ .filter((s) => !s.isEmpty)
+ .map((selection) => {
+ const range = new vscode.Range(selection.start, selection.end);
+ const contents = event.textEditor.document.getText(range);
+ return {
+ filepath: event.textEditor.document.uri.fsPath,
+ contents,
+ range: {
+ start: {
+ line: selection.start.line,
+ character: selection.start.character,
+ },
+ end: {
+ line: selection.end.line,
+ character: selection.end.character,
+ },
+ },
+ };
+ });
+ this.sendHighlightedCode(highlightedCode);
+ }, 100);
+ });
}
async handleMessage(
@@ -375,6 +404,10 @@ class IdeProtocolClient {
sendCommandOutput(output: string) {
this.messenger?.send("commandOutput", { output });
}
+
+ sendHighlightedCode(highlightedCode: (RangeInFile & { contents: string })[]) {
+ this.messenger?.send("highlightedCodePush", { highlightedCode });
+ }
}
export default IdeProtocolClient;