From 2cf4510cbd63244d83506f45e5491981d8f90f50 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 12 Oct 2026 16:35:23 +0700 Subject: [PATCH] M1: a double-click that enters a text selects all of it A double-click in the text already being edited still selects the word. --- crates/engine/src/textedit.rs | 7 ++++++- crates/engine/src/tools.rs | 8 +++++++- docs/ui-parity.md | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/textedit.rs b/crates/engine/src/textedit.rs index e031b7a4..6ba94217 100644 --- a/crates/engine/src/textedit.rs +++ b/crates/engine/src/textedit.rs @@ -582,11 +582,16 @@ mod tests { } let y = l.lines[0].top + l.lines[0].height / 2.0; let x_of = |i: usize| l.caret(i).0; - // Double-click inside "world" edits and selects the word. + // Double-click inside "world" edits with all the text selected; another one there + // selects the word. let mid = (x_of(7) + x_of(8)) / 2.0; s.pointer(&ev(PointerKind::Down, mid, y, false)).unwrap(); s.pointer(&ev(PointerKind::Up, mid, y, false)).unwrap(); s.pointer(&ev(PointerKind::DoubleClick, mid, y, false)).unwrap(); + assert_eq!(sel(&s), (0, 11)); + s.pointer(&ev(PointerKind::Down, mid, y, false)).unwrap(); + s.pointer(&ev(PointerKind::DoubleClick, mid, y, false)).unwrap(); + s.pointer(&ev(PointerKind::Up, mid, y, false)).unwrap(); assert_eq!(sel(&s), (6, 11)); // Drag-select from the start of "Hello" to the middle. s.pointer(&ev(PointerKind::Down, x_of(0) + 0.5, y, false)).unwrap(); diff --git a/crates/engine/src/tools.rs b/crates/engine/src/tools.rs index 14a6661c..c2da892f 100644 --- a/crates/engine/src/tools.rs +++ b/crates/engine/src/tools.rs @@ -1706,9 +1706,15 @@ impl Session { if doc.node(target).is_some_and(|n| matches!(n.kind, NodeKind::Text(_))) && (sel.contains(&target) || select_target(&doc, leaf, &sel, false) == target) { + // Entering a text selects all of it; in the text being edited, the word. + let editing = self.ds()?.text_edit.as_ref().is_some_and(|te| te.id == target); let idx = self.text_index_at(target, ev.p())?; textedit::begin(self, target, Some(idx), false)?; - textedit::select_word(self, idx)?; + if editing { + textedit::select_word(self, idx)?; + } else { + textedit::key(self, "SelectAll", false, false, false)?; + } return Ok(()); } // Shapes and vectors: enter vector edit mode (every selected shape, the clicked one active). diff --git a/docs/ui-parity.md b/docs/ui-parity.md index ed351784..0b36164b 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -55,7 +55,7 @@ interaction feel not yet compared. | Rotation origin (Alt+R) | done | a handle at the selection's centre to drag (snaps to the box's corners, edge middles and centre), double-click puts it back, Escape or Alt+R hides it; the corner handles, the rotation field, Rotate 90°/180° and `transform.rotate` turn about it; it follows the layers and lasts as long as the selection, not saved (the documentation doesn't say; pinned) | | Enter with a shape or frame tool chosen | done | places what a click makes (100×100, lines 100 long, sections 400×300) in the middle of the view, selected (`tool.place`); from the toolbar, Enter on the chosen tool. No crosshair to move with the arrows first | | Alt-drag duplicate | done | | -| Drag threshold; double-click into groups and text | done | a press moves or resizes only once the pointer has travelled 3 px on screen, so a click or double-click made with an unsteady hand drags nothing; a double-click goes one level into a group and the next one edits the text under it, wherever on the text it lands (`double_click_tests`) | +| Drag threshold; double-click into groups and text | done | a press moves or resizes only once the pointer has travelled 3 px on screen, so a click or double-click made with an unsteady hand drags nothing; a double-click goes one level into a group and the next one edits the text under it, wherever on the text it lands, with all of it selected (a double-click in the text being edited selects the word) (`double_click_tests`) | | Scale tool (K): handles about an anchor, live factor, panel | done | | | Nudge 1 / Shift 10 (preference), Cmd+arrows resize | done | arrows reorder auto layout children | | Smart guides: edges, centres, equal spacing (between two layers or continuing a row's gap, labelled), spacing labels, parent, layout grid, ruler guides | done | red, `snap.rs`; thresholds not yet compared with Figma's |