Engine: MidPoint finds its sketch through the store too (#5425, after #5011)

#5011 added a caller of the old `target_sketch` (MidPoint's `line_stays`, which swaps a point
picked after its line) after this branch's base. It now reads the sketch through
`sketch_store::target` and `sketch_store::read`, as the other sketch commands do, so a number
there is an exact id too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cameron Wight
2026-10-25 19:27:58 +00:00
parent 2307757ae1
commit fb99e73584
+1 -1
View File
@@ -2070,7 +2070,7 @@ fn c_midpoint(s: &mut Session, p: &Value) -> Result<Value> {
/// moves when the point can't.
fn line_stays(s: &Session, p: &Value, cmd: &str) -> Value {
let swapped = (|| {
let sk = s.doc.sketch(target_sketch(s, p, cmd).ok()?).ok()?;
let sk = sketch_store::read(&s.doc, sketch_store::target(s, p, cmd).ok()?).ok()?;
let (a, b) = (p.get("a")?.as_str()?, p.get("b")?.as_str()?);
let line = sk.curve_index(b).filter(|c| matches!(sk.curves.get(*c).map(|c| &c.kind), Some(CurveKind::Line { .. })));
(sk.curve_index(a).is_none() && sk.resolve_point(a).is_some() && line.is_some()).then(|| {