Skip to content

Commit 98c23df

Browse files
committed
fix incomplete loop group merging
1 parent 12d905f commit 98c23df

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

bhav-to-diagram.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -653,26 +653,26 @@
653653
blockLoopsSorted.forEach(blockLoop => {
654654
let intersectingLoopGroups = loopGroups
655655
.filter(loopGroup => loopGroup.blockSet.isDisjointFrom(blockLoop.blockSet) == false);
656-
656+
657657
if (intersectingLoopGroups.length === 0) {
658658
let loopGroup = {
659-
blockSet: blockLoop.blockSet,
659+
blockSet: new Set(blockLoop.blockSet),
660660
subBlockLoops: []
661661
}
662662
loopGroups.push(loopGroup);
663663
return;
664664
}
665665

666666
// merge groups
667-
let firstLoopGroup = intersectingLoopGroups[0];
668-
for (let i = 0; i < intersectingLoopGroups.length; i++) {
667+
let mainLoopGroup = intersectingLoopGroups[0];
668+
mainLoopGroup.subBlockLoops.push(blockLoop);
669+
mainLoopGroup.blockSet = mainLoopGroup.blockSet.union(blockLoop.blockSet);
670+
671+
for (let i = 1; i < intersectingLoopGroups.length; i++) {
669672
let intersectingLoopGroup = intersectingLoopGroups[i];
670-
671-
intersectingLoopGroup.subBlockLoops.push(blockLoop);
672-
intersectingLoopGroup.blockSet = intersectingLoopGroup.blockSet.union(blockLoop.blockSet);
673673

674-
if (i > 0)
675-
removeFromArray(loopGroups, intersectingLoopGroup);
674+
mainLoopGroup.blockSet = mainLoopGroup.blockSet.union(intersectingLoopGroup.blockSet);
675+
removeFromArray(loopGroups, intersectingLoopGroup);
676676
}
677677
});
678678

0 commit comments

Comments
 (0)