Skip to content

Commit 6c1cdff

Browse files
committed
contribute env var to test vsix
1 parent 46ea0b9 commit 6c1cdff

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

src/extension.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { commands, ExtensionContext, LogOutputChannel, Terminal, Uri } from 'vscode';
1+
import { commands, ExtensionContext, LogOutputChannel, Terminal, Uri, EnvironmentVariableCollection } from 'vscode';
22

33
import { PythonEnvironmentManagers } from './features/envManagers';
4-
import { registerLogger, traceInfo } from './common/logging';
4+
import { registerLogger, traceInfo, traceVerbose } from './common/logging';
55
import { EnvManagerView } from './features/views/envManagersView';
66
import {
77
addPythonProject,
@@ -66,6 +66,18 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
6666

6767
ensureCorrectVersion();
6868

69+
// Access the environment variable collection from the extension context
70+
const environmentVariableCollection: EnvironmentVariableCollection = context.environmentVariableCollection;
71+
traceInfo('Environment variable collection accessed from extension context');
72+
73+
// Optional: For debugging, log some information about the environment variable collection
74+
traceVerbose(`Environment variable collection: persistent=${environmentVariableCollection.persistent}`);
75+
76+
environmentVariableCollection.prepend('PATH', 'ENVVVVVVVVVVVEXTENSION');
77+
environmentVariableCollection.prepend('CAR', 'Maserati');
78+
// You can store the collection for later use in your extension
79+
// For example, to be accessed by other components like the environment variable manager
80+
6981
// Setup the persistent state for the extension.
7082
setPersistentState(context);
7183

src/features/execution/envVariableManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import * as path from 'path';
22
import * as fsapi from 'fs-extra';
3-
import { Uri, Event, EventEmitter, FileChangeType } from 'vscode';
3+
import { Uri, Event, EventEmitter, FileChangeType, EnvironmentVariableCollection } from 'vscode';
44
import { DidChangeEnvironmentVariablesEventArgs, PythonEnvironmentVariablesApi } from '../../api';
55
import { Disposable } from 'vscode-jsonrpc';
66
import { createFileSystemWatcher, getConfiguration } from '../../common/workspace.apis';
77
import { PythonProjectManager } from '../../internal.api';
88
import { mergeEnvVariables, parseEnvFile } from './envVarUtils';
99
import { resolveVariables } from '../../common/utils/internalVariables';
10+
import { traceVerbose } from '../../common/logging';
1011

11-
export interface EnvVarManager extends PythonEnvironmentVariablesApi, Disposable {}
12-
12+
export interface EnvVarManager extends PythonEnvironmentVariablesApi, Disposable {
1313
export class PythonEnvVariableManager implements EnvVarManager {
1414
private disposables: Disposable[] = [];
1515

0 commit comments

Comments
 (0)