From 9b3ff2c319d37a4b187e799e1cd28497a2fb2205 Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin <35292584+Myriad-Dreamin@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:04:34 +0800 Subject: [PATCH] fix: deactivate features correctly when restarting server (#1397) --- editors/vscode/src/extension.shared.ts | 4 ++-- editors/vscode/src/test/e2e/simple-docs.test.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/editors/vscode/src/extension.shared.ts b/editors/vscode/src/extension.shared.ts index 10fe754cb..1615a8d1a 100644 --- a/editors/vscode/src/extension.shared.ts +++ b/editors/vscode/src/extension.shared.ts @@ -133,8 +133,8 @@ export async function tinymistActivate( export async function tinymistDeactivate( trait: Pick, ): Promise { - for (const [condition, deactivate] of trait.activateTable()) { - if (condition) { + for (const [condition, _, deactivate] of trait.activateTable()) { + if (deactivate && condition) { deactivate(tinymist.context); } } diff --git a/editors/vscode/src/test/e2e/simple-docs.test.ts b/editors/vscode/src/test/e2e/simple-docs.test.ts index 86da3b8c4..a807b3f9e 100644 --- a/editors/vscode/src/test/e2e/simple-docs.test.ts +++ b/editors/vscode/src/test/e2e/simple-docs.test.ts @@ -106,5 +106,16 @@ export async function getTests(ctx: Context) { // close the editor await vscode.commands.executeCommand("workbench.action.closeActiveEditor"); }); + + suite.addTest("restart server", async () => { + const _mainTyp = await ctx.openDocument( + vscode.Uri.joinPath(workspaceUri, "completion-base.typ"), + ); + + await vscode.commands.executeCommand("tinymist.restartServer"); + + // close the editor + await vscode.commands.executeCommand("workbench.action.closeActiveEditor"); + }); }); }