From 0a7a02480814a3de5a4d9561e214cc92dde85c46 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 20 Apr 2021 16:26:33 -0400 Subject: [PATCH] Set lemminx debug flag when debugging lemminx Signed-off-by: David Thompson --- .vscode/launch.json | 6 ++++-- src/server/binary/binaryServerStarter.ts | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 66391de5..751c307e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,7 +12,8 @@ "outFiles": ["${workspaceRoot}/dist/**/*.js"], "preLaunchTask": "npm: watch", "env": { - "VSCODE_REDHAT_TELEMETRY_DEBUG": "true" + "VSCODE_REDHAT_TELEMETRY_DEBUG": "true", + "LEMMINX_DEBUG": "1" } }, { @@ -27,7 +28,8 @@ "preLaunchTask": "npm: watch", "env": { "SUSPEND_SERVER": "true", - "VSCODE_REDHAT_TELEMETRY_DEBUG": "true" + "VSCODE_REDHAT_TELEMETRY_DEBUG": "true", + "LEMMINX_DEBUG": "1" } }, { diff --git a/src/server/binary/binaryServerStarter.ts b/src/server/binary/binaryServerStarter.ts index b00080ce..dadd10c0 100644 --- a/src/server/binary/binaryServerStarter.ts +++ b/src/server/binary/binaryServerStarter.ts @@ -29,14 +29,13 @@ export const ABORTED_ERROR: Error = new Error('XML Language Server download canc export async function prepareBinaryExecutable(context: ExtensionContext): Promise { const binaryArgs: string = getXMLConfiguration().get("server.binary.args"); let binaryExecutable: Executable; - const proxySettings: ProxySettings = getProxySettings(); return getServerBinaryPath() .then((binaryPath: string) => { binaryExecutable = { args: [binaryArgs], command: binaryPath, options: { - env: (proxySettings ? getProxySettingsAsEnvironmentVariables(proxySettings) : {}) + env: getBinaryEnvironment() } } as Executable; return binaryPath; @@ -171,6 +170,19 @@ async function checkBinaryHash(binaryPath: string): Promise { }); } +/** + * Returns the environment variables to use to run the server as an object + * + * @returns the environment variables to use to run the server as an object + */ +function getBinaryEnvironment(): any { + const proxySettings: ProxySettings = getProxySettings(); + if (proxySettings) { + return { ...process.env, ...getProxySettingsAsEnvironmentVariables(proxySettings) }; + } + return process.env; +} + /** * Returns the name of the server binary file for the current OS and architecture *