Fix #781 regression in reconnect floating reroutes (#783)

- Follow-up on #781
- Fixes regression when reconnecting a reroute chain from an input
This commit is contained in:
filtered
2025-03-14 12:41:52 +11:00
committed by GitHub
parent 690f7bdfb3
commit 48483670f5

View File

@@ -342,18 +342,24 @@ export class LinkConnector {
if (newLink) this.events.dispatch("input-moved", renderLink)
} else {
const { node: outputNode, fromSlot, fromReroute } = renderLink
// Connect to yourself
if (fromReroute?.id === reroute.id) return
// Identical link
if (fromReroute?.id != null && fromReroute.id === reroute.parentId) return
const reroutes = reroute.getReroutes()
if (reroutes === null) throw new Error("Reroute loop detected.")
if (reroutes) {
if (reroutes && fromReroute?.id != null) {
for (const r of reroutes) {
if (r.id === fromReroute?.id) break
if (r.id === fromReroute.id) break
if (r.id === reroute.id) {
throw new Error("Cannot connect to reroute that is a parent of the reroute being connected to.")
}
}
}
if (reroutes) {
for (const reroute of reroutes.slice(0, -1).reverse()) {
if (reroute.id === fromReroute?.id) break
reroute.remove()