Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substitute environment variables in extension settings #554

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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