Skip to content

Commit

Permalink
Change applyAtProcessCreation behavior
Browse files Browse the repository at this point in the history
Part of #179476
  • Loading branch information
Tyriar committed Aug 22, 2023
1 parent 2c87822 commit c8219ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
15 changes: 9 additions & 6 deletions src/vs/workbench/api/common/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -965,22 +965,25 @@ class UnifiedEnvironmentVariableCollection {
}
const key = this.getKey(variable, mutator.scope);
const current = this.map.get(key);
const newOptions = mutator.options ? {
applyAtProcessCreation: mutator.options.applyAtProcessCreation ?? false,
applyAtShellIntegration: mutator.options.applyAtShellIntegration ?? false,
} : {
applyAtProcessCreation: true
};
if (
!current ||
current.value !== mutator.value ||
current.type !== mutator.type ||
current.options?.applyAtProcessCreation !== (mutator.options.applyAtProcessCreation ?? true) ||
current.options?.applyAtShellIntegration !== (mutator.options.applyAtShellIntegration ?? false) ||
current.options?.applyAtProcessCreation !== newOptions.applyAtProcessCreation ||
current.options?.applyAtShellIntegration !== newOptions.applyAtShellIntegration ||
current.scope?.workspaceFolder?.index !== mutator.scope?.workspaceFolder?.index
) {
const key = this.getKey(variable, mutator.scope);
const value: IEnvironmentVariableMutator = {
variable,
...mutator,
options: {
applyAtProcessCreation: mutator.options.applyAtProcessCreation ?? true,
applyAtShellIntegration: mutator.options.applyAtShellIntegration ?? false,
}
options: newOptions
};
this.map.set(key, value);
this._onDidChangeCollection.fire();
Expand Down
15 changes: 7 additions & 8 deletions src/vscode-dts/vscode.proposed.envCollectionOptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ declare module 'vscode' {
export interface EnvironmentVariableMutatorOptions {
/**
* Apply to the environment just before the process is created.
*
* Defaults to true.
*/
applyAtProcessCreation?: boolean;

/**
* Apply to the environment in the shell integration script. Note that this _will not_ apply
* the mutator if shell integration is disabled or not working for some reason.
*
* Defaults to false.
*/
applyAtShellIntegration?: boolean;
}
Expand All @@ -32,24 +28,27 @@ declare module 'vscode' {
*/
export interface EnvironmentVariableMutator {
/**
* Options applied to the mutator.
* Options applied to the mutator
*/
readonly options: EnvironmentVariableMutatorOptions;
}

export interface EnvironmentVariableCollection extends Iterable<[variable: string, mutator: EnvironmentVariableMutator]> {
/**
* @param options Options applied to the mutator.
* @param options Options applied to the mutator, when not options are provided this will
* default to `{ applyAtProcessCreation: true }`
*/
replace(variable: string, value: string, options?: EnvironmentVariableMutatorOptions): void;

/**
* @param options Options applied to the mutator.
* @param options Options applied to the mutator, when not options are provided this will
* default to `{ applyAtProcessCreation: true }`
*/
append(variable: string, value: string, options?: EnvironmentVariableMutatorOptions): void;

/**
* @param options Options applied to the mutator.
* @param options Options applied to the mutator, when not options are provided this will
* default to `{ applyAtProcessCreation: true }`
*/
prepend(variable: string, value: string, options?: EnvironmentVariableMutatorOptions): void;
}
Expand Down

0 comments on commit c8219ae

Please sign in to comment.