Fix moving output links loses subsequent reroutes

Now maintains any level of reroute chain complexity when moving links.
This commit is contained in:
filtered
2025-03-04 07:25:10 +11:00
parent 91afd9305e
commit e4a41669f6
2 changed files with 8 additions and 3 deletions

View File

@@ -2246,6 +2246,7 @@ export class LGraphCanvas implements ConnectionColorContext {
const otherNode = graph._nodes_by_id[link.target_id]
const input = otherNode.inputs[slot]
const pos = otherNode.getConnectionPos(true, slot)
const afterRerouteId = LLink.getReroutes(graph, link).at(-1)?.id
const firstRerouteId = LLink.getReroutes(graph, link).at(0)?.id
connectingLinks.push({
@@ -2255,7 +2256,8 @@ export class LGraphCanvas implements ConnectionColorContext {
output: null,
pos,
direction: LinkDirection.RIGHT,
afterRerouteId: firstRerouteId,
afterRerouteId,
firstRerouteId,
link,
})
}
@@ -4164,9 +4166,10 @@ export class LGraphCanvas implements ConnectionColorContext {
: LiteGraph.CONNECTING_LINK_COLOR
// If not using reroutes, link.afterRerouteId should be undefined.
const pos = link.afterRerouteId == null
const rerouteIdToConnectTo = link.firstRerouteId ?? link.afterRerouteId
const pos = rerouteIdToConnectTo == null
? link.pos
: (this.graph.reroutes.get(link.afterRerouteId)?.pos ?? link.pos)
: (this.graph.reroutes.get(rerouteIdToConnectTo)?.pos ?? link.pos)
const highlightPos = this.#getHighlightPosition()
// the connection being dragged by the mouse
this.renderLink(

View File

@@ -290,6 +290,8 @@ export interface ConnectingLink extends IInputOrOutput {
pos: Point
direction?: LinkDirection
afterRerouteId?: RerouteId
/** The first reroute on a chain */
firstRerouteId?: RerouteId
/** The link being moved, or `undefined` if creating a new link. */
link?: LLink
}