From b6435e1e479edb1e4f049098dc8522e944317f2a Mon Sep 17 00:00:00 2001 From: Nate Sesti <33237525+sestinj@users.noreply.github.com> Date: Tue, 22 Aug 2023 13:12:40 -0700 Subject: feat: :children_crossing: keep file context up to data by listening for filesystem events (#396) --- extension/src/continueIdeClient.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'extension/src/continueIdeClient.ts') diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index 666b8ba0..430bb9dd 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -115,6 +115,35 @@ class IdeProtocolClient { // } // }); + // Listen for new file creation + vscode.workspace.onDidCreateFiles((event) => { + const filepaths = event.files.map((file) => file.fsPath); + this.messenger?.send("filesCreated", { filepaths }); + }); + + // Listen for file deletion + vscode.workspace.onDidDeleteFiles((event) => { + const filepaths = event.files.map((file) => file.fsPath); + this.messenger?.send("filesDeleted", { filepaths }); + }); + + // Listen for file renaming + vscode.workspace.onDidRenameFiles((event) => { + const oldFilepaths = event.files.map((file) => file.oldUri.fsPath); + const newFilepaths = event.files.map((file) => file.newUri.fsPath); + this.messenger?.send("filesRenamed", { + old_filepaths: oldFilepaths, + new_filepaths: newFilepaths, + }); + }); + + // Listen for file saving + vscode.workspace.onDidSaveTextDocument((event) => { + const filepath = event.uri.fsPath; + const contents = event.getText(); + this.messenger?.send("fileSaved", { filepath, contents }); + }); + // Setup listeners for any selection changes in open editors vscode.window.onDidChangeTextEditorSelection((event) => { if (!this.editorIsCode(event.textEditor)) { -- cgit v1.2.3-70-g09d2