diff --git a/src/command/GenerateXmlCatalogCommand.ts b/src/command/GenerateXmlCatalogCommand.ts index db7ebb4..0ff72ed 100644 --- a/src/command/GenerateXmlCatalogCommand.ts +++ b/src/command/GenerateXmlCatalogCommand.ts @@ -29,7 +29,7 @@ export default class GenerateXmlCatalogCommand extends Command { const catalogLocation = Uri.joinPath(workspaceFolder.uri, '.vscode/magento-catalog.xml'); if (!(await FileSystem.fileExists(catalogLocation))) { - const success = await this.generateCatalog(workspaceFolder); + const success = await this.generateCatalog(); if (!success) { return; @@ -39,7 +39,9 @@ export default class GenerateXmlCatalogCommand extends Command { await this.formatAndWriteCatalog(catalogLocation, workspaceFolder.uri); await this.updateXmlConfig(workspaceFolder, catalogLocation); - window.showInformationMessage('XML URN catalog generated and configured successfully'); + window.showInformationMessage( + 'XML URN catalog generated and configured successfully. You might need to reload the editor for changes to take effect.' + ); } private async formatAndWriteCatalog(catalogLocation: Uri, workspaceUri: Uri) { @@ -83,24 +85,24 @@ export default class GenerateXmlCatalogCommand extends Command { await FileSystem.writeFile(catalogLocation, formattedCatalog); } - private async generateCatalog(workspaceFolder: WorkspaceFolder): Promise { - const catalogLocation = Uri.joinPath(workspaceFolder.uri, '.vscode/magento-catalog.xml'); - + private async generateCatalog(): Promise { const magentoCli = new MagentoCli(); try { - await magentoCli.run('dev:urn-catalog:generate', [catalogLocation.fsPath]); + await magentoCli.run('dev:urn-catalog:generate', ['.vscode/magento-catalog.xml']); } catch (error) { console.error(error); window.showErrorMessage( 'Failed to generate URN catalog. Try running this command manually: \n\n' + - `bin/magento dev:urn-catalog:generate ${catalogLocation.fsPath}` + `bin/magento dev:urn-catalog:generate .vscode/magento-catalog.xml` ); return false; } + magentoCli.dispose(); + return true; } diff --git a/src/common/MagentoCli.ts b/src/common/MagentoCli.ts index 583e051..3507b27 100644 --- a/src/common/MagentoCli.ts +++ b/src/common/MagentoCli.ts @@ -36,6 +36,14 @@ export default class MagentoCli { }); } + public dispose() { + const terminal = vscode.window.terminals.find(t => t.name === MagentoCli.TERMINAL_NAME); + + if (terminal) { + terminal.dispose(); + } + } + private getOrCreateTerminal(): vscode.Terminal { const terminal = vscode.window.terminals.find(t => t.name === MagentoCli.TERMINAL_NAME);