diff --git a/packages/element/src/linearElementEditor.ts b/packages/element/src/linearElementEditor.ts index 83a7d563a0..72a0406595 100644 --- a/packages/element/src/linearElementEditor.ts +++ b/packages/element/src/linearElementEditor.ts @@ -834,6 +834,11 @@ export class LinearElementEditor { let index = 0; const midpoints: (GlobalPoint | null)[] = []; while (index < points.length - 1) { + // Elbow arrows route around obstacles, so their deconstructed geometry + // can have fewer segments than there are point pairs. Suppress the + // midpoint handle for those extra pairs (no segment exists to place it + // on). For non-elbow lines/arrows segmentCount === points.length - 1, so + // this never fires. if (segmentCount > 0 && index >= segmentCount) { midpoints.push(null); index++; @@ -969,7 +974,7 @@ export class LinearElementEditor { "Only linears built out of curves are supported", ); invariant( - lines.length + curves.length >= index, + curves.length > index, "Invalid segment index while calculating mid point", );