From 6e201094c60b8f3bffb2cafc001cd7c539e4efa3 Mon Sep 17 00:00:00 2001 From: fchinu Date: Fri, 23 Oct 2026 09:19:16 +0200 Subject: [PATCH] Format Painter: compare the whole text target when a click selects text A double or triple click that moves the selection to another shape or cell at the same offsets now counts as a change and paints. Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/tools.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/tools.rs b/crates/engine/src/tools.rs index b44b6816..0857ff9c 100644 --- a/crates/engine/src/tools.rs +++ b/crates/engine/src/tools.rs @@ -34,6 +34,9 @@ pub struct Mods { pub cmd: bool, } +/// A text selection's shape, table cell, notes flag, anchor and caret. +type TextTarget = (ShapeId, Option<(usize, usize)>, bool, (usize, usize), (usize, usize)); + #[derive(Clone, Copy, Debug, Default, Serialize, Deserialize)] #[serde(default, rename_all = "camelCase")] pub struct PointerEvent { @@ -500,12 +503,13 @@ impl Session { Ok(None) } - fn text_selection(&self) -> Option<((usize, usize), (usize, usize))> { - self.active().and_then(|d| d.selection.text.as_ref()).map(|t| (t.anchor, t.caret)) + /// Where the text selection is: its shape, cell or notes, anchor and caret. + fn text_selection(&self) -> Option { + self.active().and_then(|d| d.selection.text.as_ref()).map(|t| (t.shape, t.cell, t.notes, t.anchor, t.caret)) } /// A double or triple click paints only the range it selected, not an older one it left alone. - fn paint_if_selection_changed(&mut self, before: Option<((usize, usize), (usize, usize))>, r: Value) -> Result { + fn paint_if_selection_changed(&mut self, before: Option, r: Value) -> Result { if self.text_selection() == before { return Ok(r); }