Fix scroll-anchored selection (shadowing) + IME insets keyboard handling
Two user-reported bugs in the post-wrap build:
1. Selection 'jumped' when scrolling: frameOf's chunked branch shadowed the
outer start/end with 'start, end, winLine := cb.VisibleByteRange(...)',
leaving IMEWindowStartByte at 0 for chunked files while scrolled, so the
window-relative selection highlight (and IME commits) mis-mapped near the
file top. Fix: declare winLine outside, assign. Mutation-verified
regression tests: real_file_scroll_selection_test.go.
2. Bottom bar hidden behind the keyboard: GioView extends SurfaceView, which
unconditionally marks the window FORMAT_TRANSLUCENT; translucent windows
are never IME-resized, so adjustResize is dead. Fix (build scripts):
smali-patch a PadInsetsListener OnApplyWindowInsetsListener onto the
GioView (shrinks it by the IME inset bottom) + setDecorFitsSystemWindows
(false) on API 30+ so insets are dispatched. targetSdk kept at 34.
3. (Found while fixing 2) Keyboard could not be dismissed: TextField.Draw
issued SoftKeyboardCmd{Show:true} every frame; with insets-driven
resizes, the hide animation triggered redraws that re-showed the keyboard
mid-animation. Fix: ShowIMESeq pulse from the logic layer (open/tap/
double-tap); renderer shows only on pulse change, re-arming on focus
loss — matching widget.Editor.
On-device (emulator): BACK dismisses and stays down; tap re-shows; typing
works; bottom bar above keyboard; word selection anchored across flick
scroll. go test -race ./... green. Phone APK rebuilt with the same patch.
This commit is contained in:
@@ -626,6 +626,55 @@ LINE005-vl0 — pixel-exact 1:1 finger↔content, no jump at the wrapped
|
||||
boundaries (dp 134 is where the old code jumped to LINE008); bottom clamp
|
||||
lands exactly on the file end via the wrap-aware TotalVisuals().
|
||||
|
||||
### Phase 14 — scroll-anchored selection + keyboard/bottom-bar — DONE (2026-08-17)
|
||||
|
||||
Two user-reported bugs in the post-wrap build (`83f7aff`):
|
||||
|
||||
**Bug 1 — selection "jumps" when scrolling.** Root cause was a Go variable
|
||||
shadowing regression introduced by the wrap fix: in `frameOf` the chunked
|
||||
branch declared `start, end, winLine := cb.VisibleByteRange(...)` inside an
|
||||
inner scope, shadowing the function's outer `start, end` — so
|
||||
`IMEWindowStartByte` stayed 0 for chunked (multi-chunk) files even while
|
||||
scrolled. The selection highlight (window-relative coords, mapped against
|
||||
`IMEWindowStartByte`) and IME commits while scrolled were both mis-mapped
|
||||
to near the file top. Fixed by declaring `winLine` in the outer scope and
|
||||
assigning (not re-declaring). Regression tests:
|
||||
`internal/test/e2e/real_file_scroll_selection_test.go` (window selection at
|
||||
scroll: `IMEWindowStartByte` and window-relative selection asserted; IME
|
||||
commit at scroll lands on the right line) — both mutation-verified against
|
||||
the shadowing.
|
||||
|
||||
**Bug 2 — bottom bar hidden behind the keyboard.** Root cause chain:
|
||||
`GioView extends SurfaceView` (GioView.java) → SurfaceView unconditionally
|
||||
calls `requestTransparentRegion` → the window is marked
|
||||
`FORMAT_TRANSLUCENT` (ViewRootImpl) → translucent windows are never resized
|
||||
by the IME → `windowSoftInputMode=adjustResize` is dead. No theme or
|
||||
background change can override this (verified: both patches attempted,
|
||||
format stayed TRANSLUCENT). Fix (emulator + phone build scripts): a smali
|
||||
patch adds `PadInsetsListener` (a `View$OnApplyWindowInsetsListener` on the
|
||||
GioView) and, in `GioActivity.onCreate` (API 30+ only),
|
||||
`window.setDecorFitsSystemWindows(false)` so IME insets are dispatched to
|
||||
the view; the listener shrinks the GioView by the IME inset bottom
|
||||
(`insets.getInsets(Type.ime()).bottom`), so the Go side sees a smaller
|
||||
surface and lays the bottom bar above the keyboard. On API < 30 there are
|
||||
no IME insets; the keyboard overlaps there (accepted limitation).
|
||||
|
||||
**Bug 3 (found while fixing 2) — keyboard impossible to dismiss.**
|
||||
`TextField.Draw` issued `key.SoftKeyboardCmd{Show: true}` every frame while
|
||||
focused. With the insets patch, each step of the keyboard's HIDE animation
|
||||
dispatches insets → requestLayout → surface resize → Go frame → Draw →
|
||||
show → the keyboard re-shows mid-animation. Fix: a `ShowIMESeq` pulse from
|
||||
the logic layer (bumped on file open, tap, double-tap) — the renderer
|
||||
issues show only when the pulse changes (and re-arms on focus loss),
|
||||
matching `widget.Editor`, which shows on focus gain/click only, never per
|
||||
frame.
|
||||
|
||||
**On-device (emulator):** keyboard dismisses with BACK and stays down;
|
||||
tapping the editor re-shows it; typing still works; bottom bar visible
|
||||
above the keyboard; double-tap word selection stays anchored to the same
|
||||
word across a flick scroll. `go test -race ./...` green. Phone APK rebuilt
|
||||
with the same smali patch.
|
||||
|
||||
## 6. File-size decision (re-framed)
|
||||
|
||||
v1 framed this as "accept a limit vs build a windowed editor." The live repo
|
||||
|
||||
Reference in New Issue
Block a user