-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Allow specifying workspace-specific EnvironmentVariableCollection mutators #171173
Comments
Feedback from API sync:As we anticipate we might need shell scoping as well in the future, use something similar to workspace.getConfiguration(section?: string, scope?: ConfigurationScope): WorkspaceConfiguration; instead. Updated proposal: export interface EnvironmentVariableMutator {
readonly type: EnvironmentVariableMutatorType;
readonly value: string;
readonly scope: EnvironmentVariableScope | undefined;
}
export interface EnvironmentVariableCollection extends Iterable<[variable: string, mutator: EnvironmentVariableMutator]> {
replace(variable: string, value: string, scope?: EnvironmentVariableScope): void;
append(variable: string, value: string, scope?: EnvironmentVariableScope): void;
prepend(variable: string, value: string, scope?: EnvironmentVariableScope): void;
}
export type EnvironmentVariableScope = {
/**
* The workspace folder to which this environment variable collection applies to.
* If unspecified, the collection applies to all workspace folders.
*/
workspaceFolder?: WorkspaceFolder;
}; One issue with this is that export interface EnvironmentVariableMutator {
readonly type: EnvironmentVariableMutatorType;
readonly value: string;
readonly scope: Required<EnvironmentVariableScope> | undefined;
} |
The required would need to be removed when we added a second one anyway, we can just treat |
Sorry what do you mean by the "second one"? Mostly I was trying to follow Extension-API-guidelines:
But I guess we don't have to strictly follow it? |
@karrtikr by a second one I mean a second scope, we don't want the user to explicitly enumerate all the scopes to set it which |
Updated proposal: export interface EnvironmentVariableMutator {
readonly type: EnvironmentVariableMutatorType;
readonly value: string;
readonly scope: EnvironmentVariableScope | undefined;
}
export interface EnvironmentVariableCollection extends Iterable<[variable: string, mutator: EnvironmentVariableMutator]> {
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;
}; |
Based on discussion in API sync, we should probably deprecate existing export interface ExtensionContext {
/**
* Gets the extension's environment variable collection for this workspace, enabling changes
* to be applied to terminal environment variables.
*
* @deprecated Use {@link getEnvironmentVariableCollection} instead.
*/
readonly environmentVariableCollection: EnvironmentVariableCollection;
/**
* Gets the extension's environment variable collection for this workspace, enabling changes
* to be applied to terminal environment variables.
*
* @param scope The scope to which the environment variable collection applies to.
*/
getEnvironmentVariableCollection(scope?: EnvironmentVariableScope): EnvironmentVariableCollection;
}
export type EnvironmentVariableScope = {
/**
* Any specific workspace folder to get collection for. If unspecified, collection applicable to all workspace folders is returned.
*/
workspaceFolder?: WorkspaceFolder;
}; |
Assigning myself too so it's easier for me to track 🙂 |
For microsoft/vscode#171173 #20822 To be merged tomorrow when latest insiders is released. Blocked on microsoft/vscode#189979.
@meganrogge @Tyriar When viewing contributions, is it possible to open the preview of the markdown directly instead of the as opposed to I can open preview using: |
@karrtikr since this is an advanced feature I think the raw markdown is more flexible as the user can navigate and copy section of it better. So I don't think this is a necessary change personally |
Feedback before finalization:
|
Updated proposal:export interface ExtensionContext {
/**
* Gets the extension's global environment variable collection for this workspace, enabling changes to be
* applied to terminal environment variables.
*/
readonly environmentVariableCollection: GlobalEnvironmentVariableCollection;
}
interface GlobalEnvironmentVariableCollection extends EnvironmentVariableCollection {
/**
* Gets scope-specific environment variable collection for the extension. This enables alterations to
* terminal environment variables solely within the designated scope, and is applied in addition to (and
* after) the global collection.
*
* Each object obtained through this method is isolated and does not impact objects for other scopes,
* including the global collection.
*
* @param scope The scope to which the environment variable collection applies to.
*/
getScoped(scope: EnvironmentVariableScope): EnvironmentVariableCollection;
}
export type EnvironmentVariableScope = {
/**
* Any specific workspace folder to get collection for. If unspecified, collection applicable to all workspace folders is returned.
*/
workspaceFolder?: WorkspaceFolder;
}; |
Should we also call out how it's applied in addition to (and after) the global collection? Looks good otherwise 👍 |
Sure, I have modified the docstrings to append it I plan to have the implementation ready but only merge and adopt it in Python extension next week to avoid multiple iterations. |
For microsoft/vscode#171173 microsoft#20822 To be merged tomorrow when latest insiders is released. Blocked on microsoft/vscode#189979.
For example:
Context: microsoft/vscode-python#20492 (comment)
The text was updated successfully, but these errors were encountered: