From 69b4f3ae968ae074895f96d4563642874a0c004c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 05:34:43 -0800 Subject: [PATCH] Shape tools: Backtick held at the press measures the first copy from there A drag that starts with Backtick already down set the copy spacing origin at the first drag event, so a short first stretch of the drag could leave no copy. The press now sets it. --- crates/tools/src/shape.rs | 4 ++++ crates/tools/src/shape/tests.rs | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/crates/tools/src/shape.rs b/crates/tools/src/shape.rs index b185de4c27..5d51fd8f61 100644 --- a/crates/tools/src/shape.rs +++ b/crates/tools/src/shape.rs @@ -676,6 +676,10 @@ impl Tool for ShapeTool { self.inner = None; self.before_drag = None; self.clear_copies(); + // Backtick already held at the press: the copies are measured from there. + if ev.backquote { + self.copy_from = Some(ev.pos); + } vec![] } PointerKind::Drag => { diff --git a/crates/tools/src/shape/tests.rs b/crates/tools/src/shape/tests.rs index 494ed226c1..842c0cc070 100644 --- a/crates/tools/src/shape/tests.rs +++ b/crates/tools/src/shape/tests.rs @@ -1433,6 +1433,21 @@ fn backtick_drag_leaves_copies_of_the_rectangle_being_drawn() { assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(50.0, 30.0, false))), (false, vec![40.0])); } +/// Backtick already held at the press measures the first copy from the pressed spot: the first +/// drag 10 pt away leaves one, and 5 pt more leaves none. +#[test] +fn backtick_held_at_the_press_measures_copies_from_there() { + let (d, _) = doc_with_rect(); + let s = Selection::default(); + let p = paint(); + let c = ToolContext { smart_guides: false, ..cx(&d, &s, &p) }; + let mut t = ShapeTool::new("rectangle"); + t.pointer(&c, &PointerEvent { backquote: true, ..PointerEvent::new(PointerKind::Down, 0.0, 0.0) }); + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(10.0, 10.0, true))), (true, vec![10.0])); + assert_eq!(previewed_widths(&t.pointer(&c, "e_drag(15.0, 10.0, true))), (true, vec![10.0, 15.0])); + assert_eq!(t.pointer(&c, &PointerEvent { backquote: true, ..PointerEvent::new(PointerKind::Up, 15.0, 10.0) }), vec![Action::Commit]); +} + /// Every shape tool leaves copies of its own shape, drawn with the modifiers held when each copy /// was left: Shift's square stays square, and Alt's from the centre stays centred. #[test]