From b70b586a16bc0759ca274db67e91ffca9e54179d Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Tue, 13 Oct 2026 02:22:34 -0400 Subject: [PATCH] fix(path-type): NaN-safe bracket clamping (f64::clamp panics on a NaN path length) Co-Authored-By: Claude Opus 5.5 --- crates/compose/src/lib.rs | 2 +- crates/engine/src/cmd/path_type.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index 4efd32bf5..14a97be2b 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -417,7 +417,7 @@ pub fn frame_specs(doc: &Document, sid: StoryId) -> Vec { path: None, ..tf.options.clone() }; - let end = pt.end.map_or(len, |e| e.clamp(0.0, len)); + let end = pt.end.map_or(len, |e| e.max(0.0).min(len)); (Rect::new(0.0, 0.0, (end - pt.start).max(1.0), size * 1.6), opts) } None => (item.text_area(), tf.options.clone()), diff --git a/crates/engine/src/cmd/path_type.rs b/crates/engine/src/cmd/path_type.rs index 9ce091a7e..02e5a1901 100644 --- a/crates/engine/src/cmd/path_type.rs +++ b/crates/engine/src/cmd/path_type.rs @@ -97,7 +97,7 @@ fn path_options(s: &mut Session, p: &Value) -> Result { return Ok(json!({"deleted": true})); } if let Some(v) = p.get("start").and_then(Value::as_f64).filter(|v| v.is_finite()) { - pt.start = v.clamp(0.0, len); + pt.start = v.max(0.0).min(len); } match p.get("end") { Some(Value::Null) => pt.end = None,