Pad/internal/test/e2e
Greg Pomerantz f54ca2f81a IME: map commits against the whole buffer; drop the renderer-side model
The renderer kept a mirror of the pushed IME snippet (the 'IME model')
to translate commit positions, but it transiently desynced from the
buffer on fling/tap sequences (observed as a few-byte mapping drift on
both the x86_64 emulator and the ARM phone), corrupting text. The model
string also sat on the main goroutine next to the JNI render path,
where the app observed states that were impossible for Go memory
(string contents changing between reads microseconds apart), pointing
at corruption in the native bridge layer.

Restructure along the lines of the Android InputConnection contract
and Gio's own reference editor (widget/editor.go):

- Commits carry absolute file runes (the pushed snippet's coordinate
  space) straight to the logic goroutine, which maps them to bytes
  against the WHOLE buffer (runeToByteWhole, an 8 KiB-step scan).
  Scrolling moves the window, not the buffer, so the mapping is exact
  mid-fling by construction — no mirror to desync.
- Drift guard in HandleIMECommit: a small commit (range <= 2 runes)
  is always anchored at the caret the IME was last told about; if the
  IME reports it ending elsewhere, its snippet text is stale (a
  dropped restartInput, as Gboard does during flings) and its
  position is in the stale text's coordinates — snap the commit to
  the cursor, the only position it cannot drift from.
- FlushIME simplifies to: push the snippet when the frame's
  (context+window) text differs from the last push (gioui dedupes
  against its own cache), force the selection re-push in the same
  frame. After a commit the frame text equals what the IME already
  holds locally, so the restart is naturally suppressed; a fling
  re-anchors the IME once per text change.
- Remove the renderer model (adoptFrame/ModelTranslate/
  ApplyIMEEdit/ApplyIMEKey/IMECaret), the IME freeze/settle
  machinery (IMEFrozen, markIMEScrollActive, imeSettleChan), and the
  window-relative imeRuneToByte.

Also fixed along the way (both found while chasing the corruption):

- real.ReadFileAt: loop over short reads. A single ReadAt on Android
  FUSE can return a short read, silently truncating a chunk and
  shifting every byte offset after it.
- logic: a late lazy-chunk result no longer clobbers a buffer that
  SetContent has already fully loaded.
- e2e: large-file IME test (1.6 MB file, fling + commit).
- app icon (scripts/make_icon.py + cmd/pad/appicon.png) so gogio
  builds the mipmap/adaptive icon set.

Verified: go vet + staticcheck, go test -race (all packages), and the
emulator scenario loop (open moby excerpt, fling to mid-file, tap,
type 'a', byte-compare the saved file) 75/75 clean.
2026-09-13 11:57:38 -04:00
..
assertions.go Add e2e test harness for testing editor logic without Gio display 2026-05-31 08:56:30 -04:00
browser_files_test.go Make state single-owner and stabilize race detector 2026-08-16 01:32:27 -04:00
capture.go Add e2e test harness for testing editor logic without Gio display 2026-05-31 08:56:30 -04:00
cursor_interaction_test.go Make state single-owner and stabilize race detector 2026-08-16 01:32:27 -04:00
edit_lifecycle_test.go Make state single-owner and stabilize race detector 2026-08-16 01:32:27 -04:00
find_test.go Make the editor top and bottom bars ~30% taller for bigger tap targets 2026-09-03 12:34:18 -04:00
harness_test.go gofmt: format all remaining files with the go1.27 toolchain 2026-08-23 10:03:27 -04:00
harness.go Add text selection, real-file e2e tests, and Android arrow-key support 2026-08-17 00:32:53 -04:00
helpers.go gofmt: format all remaining files with the go1.27 toolchain 2026-08-23 10:03:27 -04:00
idle_frames_test.go Add pre-release frame-regression profiling 2026-08-20 14:18:08 -04:00
real_file_chunk_boundary_test.go Add text selection, real-file e2e tests, and Android arrow-key support 2026-08-17 00:32:53 -04:00
real_file_edit_test.go Add text selection, real-file e2e tests, and Android arrow-key support 2026-08-17 00:32:53 -04:00
real_file_fuzz_test.go IME: map commits against the whole buffer; drop the renderer-side model 2026-09-13 11:57:38 -04:00
real_file_large_ime_test.go IME: map commits against the whole buffer; drop the renderer-side model 2026-09-13 11:57:38 -04:00
real_file_scroll_selection_test.go IME: map commits against the whole buffer; drop the renderer-side model 2026-09-13 11:57:38 -04:00
restore_test.go IME: map commits against the whole buffer; drop the renderer-side model 2026-09-13 11:57:38 -04:00
scroll_cursor_test.go Make editor top/bottom bars full-width; keep margin on the text area 2026-08-19 22:36:05 -04:00
search_test.go gofmt: format all remaining files with the go1.27 toolchain 2026-08-23 10:03:27 -04:00
sort_mode_test.go Make state single-owner and stabilize race detector 2026-08-16 01:32:27 -04:00
touch_selection_e2e_test.go Handle drags: 1:1 finger tracking with cross-flip; fix caret/taps on empty lines 2026-08-19 22:34:12 -04:00
type_at_start_test.go Make state single-owner and stabilize race detector 2026-08-16 01:32:27 -04:00
write_serialization_test.go Fix write-concurrency race: per-file write protocol + unique temps 2026-08-17 16:29:47 -04:00