diff --git a/core/core.ts b/core/core.ts index d63dec9f8..cbe42d7c2 100644 --- a/core/core.ts +++ b/core/core.ts @@ -934,6 +934,11 @@ export class Core { void refreshIfNotIgnored(data.uris); } }); + + on("files/closed", async ({ data }) => { + this.messenger.send("didCloseFiles", data); + }); + on("files/opened", async ({ data }) => { if (data?.uris?.length) { // Do something on files opened @@ -1003,10 +1008,6 @@ export class Core { }); on("didChangeActiveTextEditor", async ({ data: { filepath } }) => { - this.messenger.send("didChangeActiveTextEditor", { - filepath, - }); - try { const ignore = shouldIgnore(filepath, this.ide); if (!ignore) { diff --git a/core/protocol/core.ts b/core/protocol/core.ts index ac991622a..1b19a46cb 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -184,6 +184,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { "files/opened": [{ uris?: string[] }, void]; "files/created": [{ uris?: string[] }, void]; "files/deleted": [{ uris?: string[] }, void]; + "files/closed": [{ uris?: string[] }, void]; // Docs etc. Indexing. TODO move codebase to this "indexing/reindex": [{ type: string; id: string }, void]; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index def86939f..352075d2e 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -84,5 +84,5 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] = "getWebviewHistoryLength", "getCurrentSessionId", "docs/suggestions", - "didChangeActiveTextEditor", + "didCloseFiles", ]; diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index c492068d2..eb587ae60 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -26,7 +26,7 @@ export type ToWebviewFromIdeOrCoreProtocol = { }, void, ]; - didChangeActiveTextEditor: [{ filepath: string }, void]; + didCloseFiles: [{ uris: string[] }, void]; isContinueInputFocused: [undefined, boolean]; addContextItem: [ { diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index 814f6be97..41e91211c 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -310,6 +310,12 @@ export class VsCodeExtension { }); }); + vscode.workspace.onDidCloseTextDocument(async (event) => { + this.core.invoke("files/closed", { + uris: [event.uri.toString()], + }); + }); + vscode.workspace.onDidCreateFiles(async (event) => { this.core.invoke("files/created", { uris: event.files.map((uri) => uri.toString()),