From 1008514ffd8b9ab363d1a7a852f4192afc14f90b Mon Sep 17 00:00:00 2001 From: Alex Carney Date: Fri, 18 Aug 2023 17:40:54 +0100 Subject: [PATCH] code: Automatically launch `lsp-devtools tui` if appropriate --- code/src/node/client.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/code/src/node/client.ts b/code/src/node/client.ts index 405ab1b88..7e4225679 100644 --- a/code/src/node/client.ts +++ b/code/src/node/client.ts @@ -57,6 +57,8 @@ export class EsbonioClient { private client?: LanguageClient + private devtools?: vscode.TaskExecution + private handlers: Map constructor( @@ -145,6 +147,7 @@ export class EsbonioClient { let config = vscode.workspace.getConfiguration("esbonio") if (config.get('server.enableDevTools')) { + await this.startDevtools(command[0], ...command.slice(1), "-m", "lsp_devtools", "tui") command.push("-m", "lsp_devtools", "agent", "--", ...command) } @@ -301,4 +304,28 @@ export class EsbonioClient { } }) } + + private async startDevtools(command: string, ...args: string[]) { + + if (this.devtools) { + return + } + + const task = new vscode.Task( + { type: 'esbonio-devtools' }, + vscode.TaskScope.Workspace, + "lsp-devtools", + "esbonio", + new vscode.ProcessExecution( + command, + args, + { + env: { + PYTHONPATH: join(this.context.extensionPath, "bundled", "libs") + } + } + ), + ) + this.devtools = await vscode.tasks.executeTask(task) + } }