From a533aec0feac0ad0154626d38f6cadd8a0347ab3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 11:18:57 -0800 Subject: [PATCH] Transform: a line length too small to move its ends records no undo step, and both Line fields send together object.setLiveShape reports no change when the rounded ends stay where they are. The Line Length and Line Angle fields send every edited value in one call, so a length committed in the same frame as an angle step is applied. --- crates/engine/src/cmd/object/shape.rs | 2 +- crates/engine/src/tests/livecorners.rs | 6 ++++++ crates/ui-egui/src/panels/transform.rs | 12 ++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/cmd/object/shape.rs b/crates/engine/src/cmd/object/shape.rs index 0c5a16b00c..053cc3b36d 100644 --- a/crates/engine/src/cmd/object/shape.rs +++ b/crates/engine/src/cmd/object/shape.rs @@ -120,7 +120,7 @@ fn line_edit(l: &LiveShape, len: Option, angle: Option) -> Option Result { diff --git a/crates/engine/src/tests/livecorners.rs b/crates/engine/src/tests/livecorners.rs index f32d0c8257..2537748187 100644 --- a/crates/engine/src/tests/livecorners.rs +++ b/crates/engine/src/tests/livecorners.rs @@ -612,6 +612,12 @@ fn a_line_takes_its_length_and_angle() { run(&mut s, json!({"ids": [speck.0], "lineLength": 1e-12})); assert_eq!(steps(&s), n + 1, "a length of 1e-12 pt is a change"); assert!(ends(&s, speck).2 > 20.0, "{:?}", ends(&s, speck)); + // A length so short that the rounded ends do not move records no undo step. + let dust = line(&mut s, (20.0, 20.0), (20.0, 20.0)); + let n = steps(&s); + run(&mut s, json!({"ids": [dust.0], "lineLength": 1e-20})); + assert_eq!(steps(&s), n, "a length of 1e-20 pt changes nothing"); + near(ends(&s, dust), (20.0, 20.0, 20.0, 20.0)); // Other live shapes ignore the line params. let rect = NodeId(s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap()); let n = steps(&s); diff --git a/crates/ui-egui/src/panels/transform.rs b/crates/ui-egui/src/panels/transform.rs index 6145d34de3..f5ec0d18ea 100644 --- a/crates/ui-egui/src/panels/transform.rs +++ b/crates/ui-egui/src/panels/transform.rs @@ -462,22 +462,22 @@ pub(crate) fn line_rows(app: &mut VectorcraftApp, ui: &mut Ui, live: &LiveShape, } let (units, fw) = (app.session.general_unit(), super::field_width(ui)); widgets::subheader(ui, tl!("Line Properties:")); - // The `object.setLiveShape` param an edited field sets. - let mut set = None; + // The `object.setLiveShape` params the edited fields set, all sent in one call. + let mut set = serde_json::Map::new(); egui::Grid::new((id, "grid")).num_columns(2).spacing([6.0, 6.0]).show(ui, |ui| { widgets::dim_label(ui, tl!("Line Length:")); if let Some(l) = widgets::num_field_named(ui, (id, "length"), Some(tl!("Line Length:")), live.line_length(), units, fw) { - set = Some(("lineLength", json!(l))); + set.insert("lineLength".into(), json!(l)); } ui.end_row(); widgets::dim_label(ui, tl!("Line Angle:")); if let Some(a) = widgets::plain_field_named(ui, (id, "angle"), Some(tl!("Line Angle:")), live.line_angle().unwrap_or(0.0), "°", 1, fw) { - set = Some(("lineAngle", json!(a))); + set.insert("lineAngle".into(), json!(a)); } ui.end_row(); }); - if let Some((key, v)) = set - && let Err(e) = app.run("object.setLiveShape", json!({ key: v })) + if !set.is_empty() + && let Err(e) = app.run("object.setLiveShape", serde_json::Value::Object(set)) { app.status(e); }