mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-28 20:26:57 -06:00
fix(path-type): NaN-safe bracket clamping (f64::clamp panics on a NaN path length)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f96895f400
commit
b70b586a16
@@ -417,7 +417,7 @@ pub fn frame_specs(doc: &Document, sid: StoryId) -> Vec<FrameSpec> {
|
||||
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()),
|
||||
|
||||
@@ -97,7 +97,7 @@ fn path_options(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user