A cancelled drag clears its smart guides

cancel_drag cleared every preview but the smart guides, so a guide from
a cancelled move stayed on the slide through the next tool's gesture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-11-30 03:29:04 +00:00
co-authored by Claude Opus 5.5
parent 6a691fa765
commit ca339a8ec0
2 changed files with 18 additions and 0 deletions
+17
View File
@@ -1322,6 +1322,23 @@ fn a_cancelled_drag_inserts_nothing_and_puts_a_resize_back() {
assert_eq!(s.doc().unwrap().history.undo.len(), undo, "and adds no undo step");
}
/// A cancelled move takes its smart guides with it: none is left on the slide for the next tool's gesture.
#[test]
fn a_cancelled_move_leaves_no_smart_guide() {
let mut s = session();
let ev = |kind, x, y| PointerEvent { kind, x, y, mods: Mods::default(), tol: 3.0, pressure: None };
s.execute("shape.insert", &json!({"preset": "rect", "rect": [100.0, 100.0, 100.0, 80.0]})).unwrap();
let id = s.execute("shape.insert", &json!({"preset": "rect", "rect": [400.0, 300.0, 100.0, 80.0]})).unwrap()["id"].as_u64().unwrap();
s.set_tool(ToolKind::Select);
s.execute("edit.select", &json!({"ids": [id]})).unwrap();
s.pointer(ev(PointerKind::Down, 450.0, 340.0)).unwrap();
// Level with the first rectangle's top.
s.pointer(ev(PointerKind::Drag, 450.0, 142.0)).unwrap();
assert!(!s.tool.guides.is_empty(), "the moved shape shows a smart guide");
s.cancel_drag();
assert!(s.tool.guides.is_empty(), "the cancelled move leaves no guide");
}
#[test]
fn click_into_placeholder_starts_editing() {
let mut s = session();
+1
View File
@@ -228,6 +228,7 @@ impl Session {
}
self.tool.preview = None;
self.tool.marquee = None;
self.tool.guides.clear();
self.tool.path_preview.clear();
self.tool.path_closing = false;
self.tool.ink_preview.clear();