Skip to content

Commit 71a2395

Browse files
Merge pull request #14 from Acumatica/organize-import
TS server initialization and saving changes after organizeImports
2 parents ab4ae52 + 6f3a741 commit 71a2395

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

acumate-plugin/src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ function init(context: vscode.ExtensionContext) {
236236
AcuMateContext.HtmlValidator = vscode.languages.createDiagnosticCollection('htmlValidator');
237237

238238
AcuMateContext.repositoryPath = getRepositoryPath();
239+
240+
vscode.commands.executeCommand('typescript.restartTsServer');
239241
}
240242

241243
function getRepositoryPath(): string | undefined {

acumate-plugin/src/scaffolding/create-screen-extension/create-screen-extension.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,18 @@ export async function createScreenExtension() {
145145
if (uri) {
146146
const document = await vscode.workspace.openTextDocument(uri);
147147
await vscode.window.showTextDocument(document);
148-
if (AcuMateContext.ConfigurationService.clearUsages) {
149-
await vscode.commands.executeCommand(`editor.action.organizeImports`);
148+
if (AcuMateContext.ConfigurationService.clearUsages) {
149+
const handler = vscode.workspace.onDidChangeTextDocument(doc => {
150+
if (doc.document.uri.path === document.uri.path) {
151+
try {
152+
doc.document.save();
153+
} finally {
154+
handler.dispose();
155+
}
156+
}
157+
});
158+
setTimeout(() => handler.dispose(), 5000); // Fallback timeout
159+
await vscode.commands.executeCommand('editor.action.organizeImports');
150160
}
151161
}
152162
}

acumate-plugin/src/scaffolding/create-screen/create-screen.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,17 @@ export async function createScreen() {
133133
const document = await vscode.workspace.openTextDocument(uri);
134134
await vscode.window.showTextDocument(document);
135135
if (AcuMateContext.ConfigurationService.clearUsages) {
136-
await vscode.commands.executeCommand(`editor.action.organizeImports`);
136+
const handler = vscode.workspace.onDidChangeTextDocument(doc => {
137+
if (doc.document.uri.path === document.uri.path) {
138+
try {
139+
doc.document.save();
140+
} finally {
141+
handler.dispose();
142+
}
143+
}
144+
});
145+
setTimeout(() => handler.dispose(), 5000); // Fallback timeout
146+
await vscode.commands.executeCommand('editor.action.organizeImports');
137147
}
138148
}
139149
}

0 commit comments

Comments
 (0)