Skip to content

EnvironmentVariableCollection API enhancements #182069

@Tyriar

Description

@Tyriar

This issue tracks the overall improvements for the upcoming API improvements so they're all in one place:

We don't currently have a proposal for the first issue but the combined proposal for the other two is currently:

export interface EnvironmentVariableMutator {
	readonly type: EnvironmentVariableMutatorType;
	readonly value: string;
	readonly scope: EnvironmentVariableScope | undefined;
}

export interface EnvironmentVariableCollection extends Iterable<[variable: string, mutator: EnvironmentVariableMutator]> {
	/**
	 * Sets a description for the environment variable collection, this will be used to describe the changes in the UI.
	 * @param description A description for the environment variable collection.
	 * @param scope The scope to which this description applies to. If unspecified, operation applies to all
	 * workspace folders.
	 */
	setDescription(description: string | MarkdownString | undefined, scope?: EnvironmentVariableScope): void;

	replace(variable: string, value: string, scope?: EnvironmentVariableScope): void;
	append(variable: string, value: string, scope?: EnvironmentVariableScope): void;
	prepend(variable: string, value: string, scope?: EnvironmentVariableScope): void;
	get(variable: string, scope?: EnvironmentVariableScope): EnvironmentVariableMutator | undefined;
	delete(variable: string, scope?: EnvironmentVariableScope): void;
	clear(scope?: EnvironmentVariableScope): void;
}

export type EnvironmentVariableScope = {
	/**
	* The workspace folder to which this collection applies to. If unspecified, collection applies to all workspace folders.
	*/
	workspaceFolder?: WorkspaceFolder;
};

I have given feedback about scope being everywhere and maybe we should have a getScopedEnvironmentVariableCollection API on ExtensionContext instead of peppering it everywhere.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions