Skip to content

Commit 672b142

Browse files
authored
feat: ensure unique ids (#344)
1 parent e233cca commit 672b142

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/flowr/views/dependency-view.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,10 @@ class FlowrDependencyTreeView implements vscode.TreeDataProvider<Dependency> {
357357
}
358358

359359
private makeRootElements(dfi?: DataflowInformation, ast?: NormalizedAst) {
360+
const uniqueIds = new Set<string>();
360361
this.rootElements = Object.entries(dependencyDisplayInfo).map(([d, i]) => {
361362
const result = this.activeDependencies[d] as DependencyInfo[];
362-
return this.makeDependency(i.name, i.verb, result, new vscode.ThemeIcon(i.icon), d, i, dfi, ast);
363+
return this.makeDependency(i.name, i.verb, result, new vscode.ThemeIcon(i.icon), d, i, dfi, ast).enforceUniqueIds(uniqueIds);
363364
});
364365
}
365366

@@ -514,6 +515,15 @@ export class Dependency extends vscode.TreeItem {
514515
return num ? `, linked to ${num} id` + (num === 1 ? '' : 's') : '';
515516
}
516517

518+
enforceUniqueIds(seen: Set<string>) {
519+
if(seen.has(this.id ?? '')) {
520+
this.id = this.id + '-' + Math.random().toString(16).slice(2);
521+
}
522+
seen.add(this.id ?? '');
523+
this.children?.forEach(c => c.enforceUniqueIds(seen));
524+
return this;
525+
}
526+
517527
getNodeId(): NodeId | undefined {
518528
return this.info?.nodeId;
519529
}

0 commit comments

Comments
 (0)