From 05c8c7df9500964c2ddcdd915f5e6aca03840bc4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 20 Nov 2026 07:55:55 -0800 Subject: [PATCH] Quick Pen: a length drag that keeps the length records no undo step A drag across a line's length handle leaves the line's length as it was. It started an interaction and previewed the path anyway, so letting go recorded an undo step for an unchanged path. The drag now previews nothing until the length changes. --- crates/engine/src/tests/quickpen.rs | 21 +++++++++++++++++++++ crates/tools/src/quickpen.rs | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/tests/quickpen.rs b/crates/engine/src/tests/quickpen.rs index ea01f255d9..2d6ba3009f 100644 --- a/crates/engine/src/tests/quickpen.rs +++ b/crates/engine/src/tests/quickpen.rs @@ -762,6 +762,27 @@ fn a_length_drag_stays_on_the_canvas() { assert_eq!(only_path(&s).anchors.len(), 3, "the drawing went on"); } +/// A length drag across a line, which leaves its length as it was, changes nothing and records no +/// undo step, on the path being drawn and on a selected path. +#[test] +fn a_length_drag_that_keeps_the_length_records_no_undo_step() { + let mut s = session(); + quick_pen(&mut s); + click(&mut s, 100.0, 100.0); + click(&mut s, 200.0, 100.0); + let undo = undo_steps(&s); + let before = only_path(&s); + // The end handle is at (220, 100); the drag goes straight down from it. + press(&mut s, &[(220.0, 100.0), (220.0, 160.0)]); + assert_eq!(only_path(&s), before); + assert_eq!(undo_steps(&s), undo); + key(&mut s, ToolKey::Escape); + let undo = undo_steps(&s); + press(&mut s, &[(220.0, 100.0), (220.0, 160.0)]); + assert_eq!(only_path(&s), before); + assert_eq!(undo_steps(&s), undo); +} + /// The paths of a selected compound path show length handles, also after a drag selected the /// compound again. #[test] diff --git a/crates/tools/src/quickpen.rs b/crates/tools/src/quickpen.rs index dc613b9946..109d064407 100644 --- a/crates/tools/src/quickpen.rs +++ b/crates/tools/src/quickpen.rs @@ -717,7 +717,9 @@ impl QuickPenTool { if !changed.is_some_and(|sp| on_canvas(&sp)) { return vec![]; } - if drag.begun && (length - drag.length).abs() <= 1e-12 * length.max(1.0) { + // A length the end already has changes nothing: no preview, and no undo step before the + // first change. + if (length - drag.length).abs() <= 1e-12 * length.max(1.0) { return vec![]; } let mut out = vec![];