From 82a6cedb2ba7803d0c5564bb7eba1cb4dc3792c5 Mon Sep 17 00:00:00 2001 From: Alexander Rubanov Date: Thu, 4 Dec 2025 12:26:05 +0100 Subject: [PATCH 1/3] TS server initialization and saving changes after organizeImports --- acumate-plugin/src/extension.ts | 2 ++ .../create-screen-extension/create-screen-extension.ts | 10 ++++++++-- .../src/scaffolding/create-screen/create-screen.ts | 8 +++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/acumate-plugin/src/extension.ts b/acumate-plugin/src/extension.ts index 0bfe740..ef9977c 100644 --- a/acumate-plugin/src/extension.ts +++ b/acumate-plugin/src/extension.ts @@ -236,6 +236,8 @@ function init(context: vscode.ExtensionContext) { AcuMateContext.HtmlValidator = vscode.languages.createDiagnosticCollection('htmlValidator'); AcuMateContext.repositoryPath = getRepositoryPath(); + + vscode.commands.executeCommand('typescript.restartTsServer'); } function getRepositoryPath(): string | undefined { diff --git a/acumate-plugin/src/scaffolding/create-screen-extension/create-screen-extension.ts b/acumate-plugin/src/scaffolding/create-screen-extension/create-screen-extension.ts index accb30c..2791e5b 100644 --- a/acumate-plugin/src/scaffolding/create-screen-extension/create-screen-extension.ts +++ b/acumate-plugin/src/scaffolding/create-screen-extension/create-screen-extension.ts @@ -145,8 +145,14 @@ export async function createScreenExtension() { if (uri) { const document = await vscode.workspace.openTextDocument(uri); await vscode.window.showTextDocument(document); - if (AcuMateContext.ConfigurationService.clearUsages) { - await vscode.commands.executeCommand(`editor.action.organizeImports`); + if (AcuMateContext.ConfigurationService.clearUsages) { + const handler = vscode.workspace.onDidChangeTextDocument(doc => { + if (doc.document.uri.path === document.uri.path) { + doc.document.save(); + handler.dispose(); + } + }); + await vscode.commands.executeCommand('editor.action.organizeImports'); } } } \ No newline at end of file diff --git a/acumate-plugin/src/scaffolding/create-screen/create-screen.ts b/acumate-plugin/src/scaffolding/create-screen/create-screen.ts index 8f0faba..5a3dcf3 100644 --- a/acumate-plugin/src/scaffolding/create-screen/create-screen.ts +++ b/acumate-plugin/src/scaffolding/create-screen/create-screen.ts @@ -133,7 +133,13 @@ export async function createScreen() { const document = await vscode.workspace.openTextDocument(uri); await vscode.window.showTextDocument(document); if (AcuMateContext.ConfigurationService.clearUsages) { - await vscode.commands.executeCommand(`editor.action.organizeImports`); + const handler = vscode.workspace.onDidChangeTextDocument(doc => { + if (doc.document.uri.path === document.uri.path) { + doc.document.save(); + handler.dispose(); + } + }); + await vscode.commands.executeCommand('editor.action.organizeImports'); } } } From a370fc672c6ae395834036f9a9f0e9ef7a75ab07 Mon Sep 17 00:00:00 2001 From: Alexander Rubanov Date: Thu, 4 Dec 2025 14:24:22 +0100 Subject: [PATCH 2/3] Update acumate-plugin/src/scaffolding/create-screen/create-screen.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../src/scaffolding/create-screen/create-screen.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/acumate-plugin/src/scaffolding/create-screen/create-screen.ts b/acumate-plugin/src/scaffolding/create-screen/create-screen.ts index 5a3dcf3..be627a5 100644 --- a/acumate-plugin/src/scaffolding/create-screen/create-screen.ts +++ b/acumate-plugin/src/scaffolding/create-screen/create-screen.ts @@ -135,10 +135,14 @@ export async function createScreen() { if (AcuMateContext.ConfigurationService.clearUsages) { const handler = vscode.workspace.onDidChangeTextDocument(doc => { if (doc.document.uri.path === document.uri.path) { - doc.document.save(); - handler.dispose(); + try { + doc.document.save(); + } finally { + handler.dispose(); + } } }); + setTimeout(() => handler.dispose(), 5000); // Fallback timeout await vscode.commands.executeCommand('editor.action.organizeImports'); } } From 6f3a7419c40bc68c833a8ab53c918f4a6223a753 Mon Sep 17 00:00:00 2001 From: Alexander Rubanov Date: Thu, 4 Dec 2025 14:25:31 +0100 Subject: [PATCH 3/3] Update acumate-plugin/src/scaffolding/create-screen-extension/create-screen-extension.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../create-screen-extension/create-screen-extension.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/acumate-plugin/src/scaffolding/create-screen-extension/create-screen-extension.ts b/acumate-plugin/src/scaffolding/create-screen-extension/create-screen-extension.ts index 2791e5b..82ac34b 100644 --- a/acumate-plugin/src/scaffolding/create-screen-extension/create-screen-extension.ts +++ b/acumate-plugin/src/scaffolding/create-screen-extension/create-screen-extension.ts @@ -148,10 +148,14 @@ export async function createScreenExtension() { if (AcuMateContext.ConfigurationService.clearUsages) { const handler = vscode.workspace.onDidChangeTextDocument(doc => { if (doc.document.uri.path === document.uri.path) { - doc.document.save(); - handler.dispose(); + try { + doc.document.save(); + } finally { + handler.dispose(); + } } }); + setTimeout(() => handler.dispose(), 5000); // Fallback timeout await vscode.commands.executeCommand('editor.action.organizeImports'); } }