Delete scope property if undefined

This commit is contained in:
Kartik Raj 2023-04-20 20:22:46 +00:00
parent 9d68cc5532
commit 69e919cc0e
2 changed files with 10 additions and 3 deletions

View file

@ -39,14 +39,18 @@ export class MergedEnvironmentVariableCollection implements IMergedEnvironmentVa
continue;
}
// Mutators get applied in the reverse order than they are created
entry.unshift({
const extensionMutator = {
extensionIdentifier,
value: mutator.value,
type: mutator.type,
scope: mutator.scope,
variable: mutator.variable
});
};
if (!extensionMutator.scope) {
delete extensionMutator.scope; // Convenient for tests
}
// Mutators get applied in the reverse order than they are created
entry.unshift(extensionMutator);
next = it.next();
}

View file

@ -902,6 +902,9 @@ class EnvironmentVariableCollection implements vscode.EnvironmentVariableCollect
}
private _setIfDiffers(variable: string, mutator: vscode.EnvironmentVariableMutator): void {
if (!mutator.scope) {
delete (mutator as any).scope; // Convenient for tests
}
const key = this.getKey(variable, mutator.scope);
const current = this.map.get(key);
if (!current || current.value !== mutator.value || current.type !== mutator.type || current.scope?.workspaceFolder?.index !== mutator.scope?.workspaceFolder?.index) {