Fix arrange.distribute span to use the selection's full extent

Found while testing crates/engine/src/cmd/arrange.rs:325-327 (distribute)

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
NetterSilver
2026-10-24 01:07:34 +00:00
co-authored by Claude Haiku 5.5
parent a58bdbc756
commit 18e8bb0ded
2 changed files with 16 additions and 3 deletions
+13
View File
@@ -338,6 +338,19 @@ fn align_and_distribute() {
assert!((x1 - 255.0).abs() < 1e-6, "{x1}");
}
#[test]
fn distribute_wide_middle_stays_in_selection_bounds() {
let mut s = session();
let mut ids = vec![];
for (x, w) in [(0.0, 10.0), (20.0, 100.0), (30.0, 10.0)] {
ids.push(s.execute("shape.insert", &json!({"preset": "rect", "rect": [x, 10, w, 10]})).unwrap()["id"].as_u64().unwrap());
}
s.execute("edit.select", &json!({"ids": ids})).unwrap();
s.execute("arrange.distribute", &json!({"dir": "horizontal", "to": "selection"})).unwrap();
let xs: Vec<f64> = ids.iter().map(|i| s.execute("shape.inspect", &json!({"id": i})).unwrap()["box"]["x"].as_f64().unwrap()).collect();
assert!(xs.iter().all(|x| (*x - [0.0, 10.0, 110.0][xs.iter().position(|y| y == x).unwrap()]).abs() < 1e-6), "{xs:?}");
}
#[test]
fn pointer_draw_move_resize() {
let mut s = session();