From 99150ea161ced3b5be505a8937f40d2bc779a960 Mon Sep 17 00:00:00 2001 From: Mark Tolmacs Date: Tue, 7 Jul 2026 08:05:22 +0000 Subject: [PATCH] fix: Tighten curve index in linear sampling Signed-off-by: Mark Tolmacs --- packages/element/src/linearElementEditor.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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", );