mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-24 10:27:44 -06:00
gap: single cell border: only a triple-click selects the cell, not the ribbon's Select Paragraph
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
d9467df1c0
commit
5aa87f27f3
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user