Support diffs of collections, extracting additions

This commit is contained in:
Daniel Imms
2020-03-26 16:51:04 -07:00
parent edc7100114
commit 1235bd0a60
7 changed files with 181 additions and 184 deletions

View File

@@ -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();
}
}