From ecc759ba850683c4b79292fd1e19c5ccb874f8a6 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 24 Jul 2024 00:19:35 +0530 Subject: [PATCH] Substitute environment variables in extension settings --- src/common/server.ts | 20 +++----------------- src/common/settings.ts | 5 +++++ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/common/server.ts b/src/common/server.ts index 3369b7d..5f96e7a 100644 --- a/src/common/server.ts +++ b/src/common/server.ts @@ -35,7 +35,7 @@ import { NATIVE_SERVER_STABLE_VERSION, } from "./version"; import { updateServerKind, updateStatus } from "./status"; -import { isVirtualWorkspace } from "./vscodeapi"; +import { getDocumentSelector } from "./utilities"; import { execFile } from "child_process"; import which = require("which"); @@ -188,14 +188,7 @@ async function createNativeServer( const clientOptions = { // Register the server for python documents - documentSelector: isVirtualWorkspace() - ? [{ language: "python" }] - : [ - { scheme: "file", language: "python" }, - { scheme: "untitled", language: "python" }, - { scheme: "vscode-notebook", language: "python" }, - { scheme: "vscode-notebook-cell", language: "python" }, - ], + documentSelector: getDocumentSelector(), outputChannel: outputChannel, traceOutputChannel: outputChannel, revealOutputChannelOn: RevealOutputChannelOn.Never, @@ -243,14 +236,7 @@ async function createLegacyServer( // Options to control the language client const clientOptions: LanguageClientOptions = { // Register the server for python documents - documentSelector: isVirtualWorkspace() - ? [{ language: "python" }] - : [ - { scheme: "file", language: "python" }, - { scheme: "untitled", language: "python" }, - { scheme: "vscode-notebook", language: "python" }, - { scheme: "vscode-notebook-cell", language: "python" }, - ], + documentSelector: getDocumentSelector(), outputChannel: outputChannel, traceOutputChannel: outputChannel, revealOutputChannelOn: RevealOutputChannelOn.Never, diff --git a/src/common/settings.ts b/src/common/settings.ts index c01f688..86aaa52 100644 --- a/src/common/settings.ts +++ b/src/common/settings.ts @@ -92,6 +92,11 @@ function resolveVariables( getWorkspaceFolders().forEach((w) => { substitutions.set("${workspaceFolder:" + w.name + "}", w.uri.fsPath); }); + for (const [key, value] of Object.entries(process.env)) { + if (value !== undefined) { + substitutions.set("${env:" + key + "}", value); + } + } if (typeof value === "string") { let s = value;