Hole: editing a Single hole replaces the picked face (#10692) (#10797)

The editor reused the new-hole Face input, which is multi, so a second pick
appended and OK silently kept the first. Editing now makes that input single,
so a pick replaces the place.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Vvynot
2026-11-02 14:45:37 +00:00
committed by GitHub
parent 01b592e0c8
commit ec1f78c6fa
2 changed files with 29 additions and 0 deletions
+4
View File
@@ -6085,6 +6085,8 @@ pub fn for_feature(app: &SolveApp, id: u64, marker: Option<usize>) -> Option<Dia
.and_then(|ss| ss.sketch.points.iter().find(|p| p.id == id).map(|p| ss.plane.to_world(p.pos)))
.unwrap_or(position.0);
if let Some(inp) = d.inputs.first_mut() {
// Editing a Single hole places it at exactly one point: a pick replaces.
inp.multi = false;
inp.items = vec![face_sel(s, at).unwrap_or(Sel::Face { body: String::new(), index: 0, point: at })];
}
d.extra.insert("direction".into(), pt3(direction.0));
@@ -6106,6 +6108,8 @@ pub fn for_feature(app: &SolveApp, id: u64, marker: Option<usize>) -> Option<Dia
// when the pick is still that point (a moved face drops them for numbers).
let on_face = solidcraft_engine::doc::hole_on_surface(&s.world_state(), position.0, direction.0, &[]);
if let Some(inp) = d.inputs.first_mut() {
// Editing a Single hole places it at exactly one point: a pick replaces.
inp.multi = false;
inp.items = vec![face_sel(s, on_face).unwrap_or(Sel::Face { body: String::new(), index: 0, point: on_face })];
}
d.extra.insert("direction".into(), pt3(direction.0));
+25
View File
@@ -360,3 +360,28 @@ fn hole_design_preferences_keep_both_controls_and_cancel_after_page_split() {
h.call("ui.prefs", json!({"button":"cancel"}));
assert!(!h.app.preferences.hole_snaps && !h.app.preferences.hole_moves);
}
#[test]
fn editing_a_hole_replaces_its_face_instead_of_adding_one() {
// #10692: a Single hole has one place; a second face pick while editing replaces it.
let mut h = Harness::new();
h.app.set_origin_shown(false);
h.app.run("solid.box", json!({"length": 40, "width": 30, "height": 10, "body_name": "Base"})).unwrap();
h.app.run("solid.box", json!({"corner": [0, 0, 10], "length": 20, "width": 30, "height": 10, "operation": "new", "body_name": "Top"})).unwrap();
let hole = h.app.run("solid.hole", json!({"position": [30, 15, 10], "diameter": 6, "name": "Hole1"})).unwrap()["feature"].as_u64().unwrap();
h.step(&json!({"call": "ui.view", "params": {"view": "top"}})).unwrap();
h.settle();
h.step(&json!({"call": "ui.editFeature", "params": {"feature": hole}})).unwrap();
h.frames(3);
assert_eq!(h.app.dialog.as_ref().unwrap().inputs[0].items.len(), 1, "one place on opening");
let on_top = Vec3::new(10.0, 15.0, 20.0);
let at = screen(&mut h, on_top);
h.step(&json!({"click": at})).unwrap();
assert_eq!(h.app.dialog.as_ref().unwrap().inputs[0].items.len(), 1, "the pick replaces the place, not '2 selected'");
assert!(matches!(places(&h).as_slice(), [p] if p.dist(on_top) < 1e-3), "{:?}", places(&h));
h.step(&json!({"key": "Enter"})).unwrap();
assert!(h.app.dialog.is_none(), "{:?}", h.app.dialog.as_ref().map(|d| &d.error));
let (again, position) = last_hole(&h);
assert_eq!(again, hole, "the same feature");
assert!(position.dist(on_top) < 1e-3, "OK uses the new face: {position:?}");
}