fix: protocols

This commit is contained in:
tomasz-io 2025-03-11 10:58:48 -07:00
parent be153f8ab9
commit c8a24c0c90
5 changed files with 14 additions and 6 deletions

View file

@ -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) {

View file

@ -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];

View file

@ -84,5 +84,5 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] =
"getWebviewHistoryLength",
"getCurrentSessionId",
"docs/suggestions",
"didChangeActiveTextEditor",
"didCloseFiles",
];

View file

@ -26,7 +26,7 @@ export type ToWebviewFromIdeOrCoreProtocol = {
},
void,
];
didChangeActiveTextEditor: [{ filepath: string }, void];
didCloseFiles: [{ uris: string[] }, void];
isContinueInputFocused: [undefined, boolean];
addContextItem: [
{

View file

@ -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()),