Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected updateModels = debounce(async () => {
const roots = await this.workspaceService.roots;
const toDelete = new Set(this.models.keys());
for (const rootStat of roots) {
const key = rootStat.uri;
toDelete.delete(key);
if (!this.models.has(key)) {
const model = new TaskConfigurationModel(key, this.preferences);
model.onDidChange(() => this.onDidChangeTaskConfigEmitter.fire({ uri: key, type: FileChangeType.UPDATED }));
model.onDispose(() => this.models.delete(key));
this.models.set(key, model);
this.onDidChangeTaskConfigEmitter.fire({ uri: key, type: FileChangeType.UPDATED });
}
}
for (const uri of toDelete) {
const model = this.models.get(uri);
if (model) {
model.dispose();
}
this.onDidChangeTaskConfigEmitter.fire({ uri, type: FileChangeType.DELETED });
}
}, 500);
model.onDidChange(() => this.onDidChangeTaskConfigEmitter.fire({ uri: key, type: FileChangeType.UPDATED }));
model.onDispose(() => this.models.delete(key));