Block duplication in nested loop save fix (#4342)
This commit is contained in:
@@ -2352,6 +2352,19 @@ function getOrderedChildrenBlocks(
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This prevents nested loop children from being added to the parent loop.
|
||||||
|
const isInsideIncludedLoop = (nodeId: string): boolean => {
|
||||||
|
let current = nodesById.get(nodeId);
|
||||||
|
while (current?.parentId) {
|
||||||
|
const parent = nodesById.get(current.parentId);
|
||||||
|
if (parent?.type === "loop" && includedIds.has(parent.id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
current = parent;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
const parentNode = nodes.find((node) => node.id === parentId);
|
const parentNode = nodes.find((node) => node.id === parentId);
|
||||||
if (!parentNode) {
|
if (!parentNode) {
|
||||||
return [];
|
return [];
|
||||||
@@ -2410,6 +2423,9 @@ function getOrderedChildrenBlocks(
|
|||||||
if (!hasAncestor(node.id, parentId)) {
|
if (!hasAncestor(node.id, parentId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isInsideIncludedLoop(node.id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (node.type === "loop") {
|
if (node.type === "loop") {
|
||||||
const loopChildren = getOrderedChildrenBlocks(nodes, edges, node.id);
|
const loopChildren = getOrderedChildrenBlocks(nodes, edges, node.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user