From 717fcd6decef246b84797e2e9086a001eae3df74 Mon Sep 17 00:00:00 2001 From: paaspaas00 <151774837+paaspaas00@users.noreply.github.com> Date: Wed, 21 Oct 2026 12:00:01 +0200 Subject: [PATCH] Type tool: a release away from the press doesn't convert the empty frame Co-Authored-By: Claude Opus 5.5 --- crates/tools/src/tests.rs | 3 +++ crates/tools/src/text.rs | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/tools/src/tests.rs b/crates/tools/src/tests.rs index 5295708cb..2e5ded8a3 100644 --- a/crates/tools/src/tests.rs +++ b/crates/tools/src/tests.rs @@ -1080,6 +1080,9 @@ fn type_tool_drag_over_an_empty_frame_draws_a_new_text_frame() { assert!(t.pointer(&cx, &PointerEvent::new(PointerKind::Down, x, y)).is_empty()); let a = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, x, y)); assert!(matches!(&a[..], [Action::Exec(cmd, p)] if cmd == "text.placeCaret" && p["frame"] == id.0), "{a:?}"); + // A release away from the press with no drag in between isn't a click: no caret, no conversion. + assert!(t.pointer(&cx, &PointerEvent::new(PointerKind::Down, x, y)).is_empty()); + assert!(t.pointer(&cx, &PointerEvent::new(PointerKind::Up, x1, y1)).is_empty()); } #[test] diff --git a/crates/tools/src/text.rs b/crates/tools/src/text.rs index c8cb778a9..e7ac00355 100644 --- a/crates/tools/src/text.rs +++ b/crates/tools/src/text.rs @@ -333,8 +333,12 @@ impl Tool for TypeTool { self.selecting = None; return vec![Action::Commit]; } - // A click in an empty frame: it becomes a text frame with the caret in it. + // A click in an empty frame: it becomes a text frame with the caret in it. A release + // away from the press (with no drag in between) isn't a click: nothing changes. if let Some((fid, at)) = self.convert.take() { + if start.is_some_and(|a| (ev.pos - a).hypot() >= cx.tol(3.0)) { + return vec![]; + } return vec![Action::Exec("text.placeCaret".into(), json!({"frame": fid, "point": [at.x, at.y]}))]; } // Ends a press in text: drops dragged text, or is ignored by the engine.