From 598bf4c45b9311914556482883f06b0889a14c9a Mon Sep 17 00:00:00 2001 From: Alex Carney Date: Sun, 27 Aug 2023 19:02:48 +0100 Subject: [PATCH] code: Ensure lsp-devtools can be relaunched when closed --- code/src/node/client.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/code/src/node/client.ts b/code/src/node/client.ts index 7e4225679..5257be59b 100644 --- a/code/src/node/client.ts +++ b/code/src/node/client.ts @@ -69,9 +69,19 @@ export class EsbonioClient { ) { this.handlers = new Map() + // Restart server implementation context.subscriptions.push( vscode.commands.registerCommand(Commands.RESTART_SERVER, async () => await this.restartServer()) ) + + // Unset devtools task when it finishes. + context.subscriptions.push( + vscode.tasks.onDidEndTask((event) => { + if (event.execution === this.devtools) { + this.devtools = undefined + } + }) + ) } public addHandler(event: string, handler: any) { @@ -146,8 +156,14 @@ export class EsbonioClient { command.push("-S") let config = vscode.workspace.getConfiguration("esbonio") - if (config.get('server.enableDevTools')) { + let serverDevtools = config.get('server.enableDevTools') + let sphinxDevtools = config.get('sphinx.enableDevTools') + + if (serverDevtools || sphinxDevtools) { await this.startDevtools(command[0], ...command.slice(1), "-m", "lsp_devtools", "tui") + } + + if (serverDevtools) { command.push("-m", "lsp_devtools", "agent", "--", ...command) }