From 5e2a3fc62ff6bf02c2ed24a7fa9f2d875aa343c7 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 8 Sep 2026 14:28:00 +0200 Subject: [PATCH] fix: keep the start handle on a paragraph's first word Long-pressing the first word of a paragraph selected it but painted the start handle on the paragraph's last hyphen, or off the page when that hyphen was in another column. Dragging then grabbed the whole paragraph and the reader could not shrink it. This is an Android WebView bug (Chromium 522869957): a hyphen's offsets are relative to itself, so a selection starting at the very beginning of a paragraph makes every hyphen claim the start bound. Each block that opens with text now begins with two invisible non-breaking spaces at zero size, so the real first letter is never at the offset that trips the bug. Nothing moves on the page, drop caps keep their letter, and highlights and positions never see the spaces. Blocks that only contain other blocks, and blocks whose author already generates content there, are left alone. Closes #189 Refs #125 --- AGENTS.md | 16 ++ .../com/chmouel/liseur/reader/ReaderScreen.kt | 17 +- .../liseur/reader/SelectionHandleFix.kt | 271 ++++++++++++++++++ .../liseur/reader/SelectionHandleFixTest.kt | 175 +++++++++++ 4 files changed, 474 insertions(+), 5 deletions(-) create mode 100644 app/src/main/kotlin/com/chmouel/liseur/reader/SelectionHandleFix.kt create mode 100644 app/src/test/kotlin/com/chmouel/liseur/reader/SelectionHandleFixTest.kt diff --git a/AGENTS.md b/AGENTS.md index 07267ea4..b7e6f00e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -446,4 +446,20 @@ emulator. the gesture — leaving, a rotation, a window resize — goes through `PageTurnDrag.abandon`, which puts the page back without animating, since an animation wants a next frame there may not be one of. +- What a stylesheet alone cannot put right in the book's document is + repaired in the page by `repairPage()`: `WideContentFit`, + `FootnoteLayout` and `SelectionHandleFix` each inject a runtime + `