From 5aa87f27f3573549fdada6927411ea56f14ad49c Mon Sep 17 00:00:00 2001 From: Dmitrii Khlapov <19991457+dkhlapov@users.noreply.github.com> Date: Sun, 18 Oct 2026 17:43:19 +0200 Subject: [PATCH] gap: single cell border: only a triple-click selects the cell, not the ribbon's Select Paragraph Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/cmd/caret.rs | 10 +++++++--- crates/engine/src/cmd/table_resize.rs | 5 ++++- crates/ui-egui/src/canvas.rs | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/caret.rs b/crates/engine/src/cmd/caret.rs index 4ab47171f..12a65494f 100644 --- a/crates/engine/src/cmd/caret.rs +++ b/crates/engine/src/cmd/caret.rs @@ -378,10 +378,14 @@ fn select_sentence(s: &mut Session, _: &Value) -> CmdResult { select_unit(s, Unit::Sentence) } -/// A triple-click on the last paragraph of a table cell selects the cell (Word takes its end -/// mark too, which shades it), so its borders then move on their own (`table.resizeDrag`). -fn select_paragraph(s: &mut Session, _: &Value) -> CmdResult { +/// A triple-click (`cell: true`) on the last paragraph of a table cell selects the cell (Word +/// takes its end mark too, which shades it), so its borders then move on their own +/// (`table.resizeDrag`). Without `cell` (the ribbon's Select Paragraph) only the paragraph is selected. +fn select_paragraph(s: &mut Session, v: &Value) -> CmdResult { let r = select_unit(s, Unit::Paragraph); + if v.get("cell").and_then(Value::as_bool) != Some(true) { + return r; + } let (a, b) = (s.sel.anchor.clone(), s.sel.focus.clone()); let n = a.path.0.len(); if a.story == b.story diff --git a/crates/engine/src/cmd/table_resize.rs b/crates/engine/src/cmd/table_resize.rs index 20af69360..af51c22fd 100644 --- a/crates/engine/src/cmd/table_resize.rs +++ b/crates/engine/src/cmd/table_resize.rs @@ -1028,7 +1028,7 @@ mod tests { } "triple" => { s.run("caret.set", &json!({"page": 0, "x": b.x + b.w / 2.0, "y": y})).unwrap(); - s.run("select.paragraph", &json!({})).unwrap(); + s.run("select.paragraph", &json!({"cell": true})).unwrap(); } _ => { s.run("caret.set", &json!({"page": 0, "x": b.x + b.w / 2.0, "y": y})).unwrap(); @@ -1131,6 +1131,9 @@ mod tests { s.run("text.insert", &json!({"text": "Two"})).unwrap(); s.run("select.text", &json!({"text": if last { "Two" } else { "One" }})).unwrap(); s.run("select.paragraph", &json!({})).unwrap(); + assert!(s.cell_range().is_none(), "the ribbon's Select Paragraph never selects the cell"); + s.run("select.text", &json!({"text": if last { "Two" } else { "One" }})).unwrap(); + s.run("select.paragraph", &json!({"cell": true})).unwrap(); assert_eq!(s.cell_range().is_some(), last); let b = cell_rect(&mut s, 1, 1); let y = b.y + b.h / 2.0; diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 38f8d1d21..88e645c55 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -2372,7 +2372,7 @@ fn mouse(app: &mut WordApp, ui: &Ui, resp: &egui::Response, rects: &[Rect], layo return; } if resp.triple_clicked() { - let _ = app.run("select.paragraph", json!({})); + let _ = app.run("select.paragraph", json!({"cell": true})); return; } let pressed = ui.input(|i| i.pointer.primary_pressed()) && resp.contains_pointer() && !over_balloon(app, p);