Skip to content

Commit

Permalink
Substitute environment variables in extension settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Jul 23, 2024
1 parent 56a098c commit f818b07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/common/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f818b07

Please sign in to comment.