mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
Support diffs of collections, extracting additions
This commit is contained in:
@@ -648,50 +648,50 @@ export class EnvironmentVariableMutator implements vscode.EnvironmentVariableMut
|
||||
}
|
||||
|
||||
export class EnvironmentVariableCollection implements vscode.EnvironmentVariableCollection {
|
||||
public entries: Map<string, EnvironmentVariableMutator> = new Map();
|
||||
public map: Map<string, EnvironmentVariableMutator> = new Map();
|
||||
|
||||
protected readonly _onDidChangeCollection: Emitter<void> = new Emitter<void>();
|
||||
get onDidChangeCollection(): Event<void> { return this._onDidChangeCollection && this._onDidChangeCollection.event; }
|
||||
|
||||
get size(): number {
|
||||
return this.entries.size;
|
||||
return this.map.size;
|
||||
}
|
||||
|
||||
replace(variable: string, value: string): void {
|
||||
this.entries.set(variable, new EnvironmentVariableMutator(value, EnvironmentVariableMutatorType.Replace));
|
||||
this.map.set(variable, new EnvironmentVariableMutator(value, EnvironmentVariableMutatorType.Replace));
|
||||
this._onDidChangeCollection.fire();
|
||||
}
|
||||
|
||||
append(variable: string, value: string): void {
|
||||
this.entries.set(variable, new EnvironmentVariableMutator(value, EnvironmentVariableMutatorType.Append));
|
||||
this.map.set(variable, new EnvironmentVariableMutator(value, EnvironmentVariableMutatorType.Append));
|
||||
this._onDidChangeCollection.fire();
|
||||
}
|
||||
|
||||
prepend(variable: string, value: string): void {
|
||||
this.entries.set(variable, new EnvironmentVariableMutator(value, EnvironmentVariableMutatorType.Prepend));
|
||||
this.map.set(variable, new EnvironmentVariableMutator(value, EnvironmentVariableMutatorType.Prepend));
|
||||
this._onDidChangeCollection.fire();
|
||||
}
|
||||
|
||||
get(variable: string): EnvironmentVariableMutator | undefined {
|
||||
return this.entries.get(variable);
|
||||
return this.map.get(variable);
|
||||
}
|
||||
|
||||
forEach(callback: (variable: string, mutator: vscode.EnvironmentVariableMutator, collection: vscode.EnvironmentVariableCollection) => any, thisArg?: any): void {
|
||||
this.entries.forEach((value, key) => callback(key, value, this));
|
||||
this.map.forEach((value, key) => callback(key, value, this));
|
||||
}
|
||||
|
||||
delete(variable: string): void {
|
||||
this.entries.delete(variable);
|
||||
this.map.delete(variable);
|
||||
this._onDidChangeCollection.fire();
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this.entries.clear();
|
||||
this.map.clear();
|
||||
this._onDidChangeCollection.fire();
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.entries.clear();
|
||||
this.map.clear();
|
||||
this._onDidChangeCollection.fire();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user