Pad/internal/editor
Greg Pomerantz 0f1b6e6290 Hold the restored scroll on its line while wrap counts settle (spec §2.4)
On device (Pixel 9 Pro) the relaunch landed further UP than the saved
position: while the restore scroll is still armed (scale + size + content
can take ~600 ms), the top-of-file window is what gets rendered, and its
shaping feedback — real wrap counts for lines ABOVE the restored line —
lands before or just after the offset is applied. The counts are correct
data, but they change V(line), so the line-derived offset (synthesized
for the all-estimate index) maps to a shallower line and the viewport
drifts up; the save then persists the drifted line and every subsequent
relaunch lands there.

Fix: the restore pins the logical line. Until the restored window's own
shaping arrives (or a 2 s timeout, or the user scrolls / a search jumps),
every accepted wrap correction re-derives the offset as
VisualsBefore(line)*lh + sub under the corrected index. The pin refresh
does not clamp to MaxScroll: the correction just grew the index, so the
pre-layout clamp value is stale and would under-clamp the re-derived
offset (the layout of the emitted frame clamps to the fresh value).

Also: the apply-time offset is mapped through VisualsBefore under the
current index (identical to line*lh while the index is all estimates),
so pre-apply corrections are absorbed instead of gated away.

Verified on device: saved line 420 -> restored 420 (was 333); saved 573
(near EOF, clamp territory) -> restored 573. New e2e regression
TestRestore_LinePinHoldsAcrossLateWrapFeedback replays the late
top-window feedback and fails pre-fix (window drifts 200 -> 66).
2026-08-20 21:03:56 -04:00
..
auto_save_test.go Fix test build after NewLogic signature change; add development plan draft 2026-08-15 22:18:04 -04:00
buffer_test.go fix(editor): wire key events to cursor movement 2026-06-03 07:41:18 -04:00
chunked_buffer_fuzz_test.go Data-corruption test suite: differential fuzz + atomicity contract 2026-08-17 12:43:17 -04:00
chunked_buffer_test.go Add text selection, real-file e2e tests, and Android arrow-key support 2026-08-17 00:32:53 -04:00
chunked_buffer.go Fix word-wrap scroll jump: visual-line mapping via WrapIndex 2026-08-17 19:46:47 -04:00
cursor_test.go Fix word-wrap scroll jump: visual-line mapping via WrapIndex 2026-08-17 19:46:47 -04:00
deterministic_file.go feat: virtual scrolling with chunked buffer for large files 2026-06-05 09:11:32 -04:00
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
filename_test.go Collapse editor top bar to one row (back + filename) 2026-08-18 08:32:19 -04:00
find_scroll_test.go Fix find scroll position on long files 2026-08-20 06:50:14 -04:00
font_scale_test.go Track Android user font scale in all line-height geometry (Phase 11) 2026-08-17 10:59:34 -04:00
frame.go Fix relaunch-restore bugs found on device (spec §7 verification) 2026-08-20 17:31:55 -04:00
ime_range_test.go editor: fix viewport-on-open, chunked-buffer drift, add size guard (Phase 3 code) 2026-08-16 10:35:10 -04:00
integration_test.go editor+ui: complete Android IME wiring (SelectionCmd, SnippetCmd, InputHintOp) 2026-08-16 02:43:58 -04:00
line_index_fuzz_test.go Data-corruption test suite: differential fuzz + atomicity contract 2026-08-17 12:43:17 -04:00
logic.go Hold the restored scroll on its line while wrap counts settle (spec §2.4) 2026-08-20 21:03:56 -04:00
mock_setup.go Handle drags: 1:1 finger tracking with cross-flip; fix caret/taps on empty lines 2026-08-19 22:34:12 -04:00
perf_probe.go perf: default-off in-app profiler + debug scroll jumps; verify scroll perf & clamping 2026-08-16 16:53:28 -04:00
scroll_fix_test.go WIP baseline: Termux open-file bridge + word-wrap-aware viewport/scroll 2026-08-16 00:31:26 -04:00
search_test.go Stop the find input clearing itself while typing 2026-08-20 13:22:50 -04:00
search.go Hold the restored scroll on its line while wrap counts settle (spec §2.4) 2026-08-20 21:03:56 -04:00
selection_menu_track_test.go Make editor top/bottom bars full-width; keep margin on the text area 2026-08-19 22:36:05 -04:00
selection_test.go Add text selection, real-file e2e tests, and Android arrow-key support 2026-08-17 00:32:53 -04:00
session.go Hold the restored scroll on its line while wrap counts settle (spec §2.4) 2026-08-20 21:03:56 -04:00
state_api_fuzz_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
state.go Hold the restored scroll on its line while wrap counts settle (spec §2.4) 2026-08-20 21:03:56 -04:00
tap_scroll_property_test.go Prove tap-to-position is scroll-offset independent; fix float32 decomposition bug 2026-08-17 09:57:21 -04:00
touch_selection_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
wrap_apply_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
wrap_bookkeeping_test.go Fix word-wrap scroll jump: visual-line mapping via WrapIndex 2026-08-17 19:46:47 -04:00
wrap_index_test.go Fix word-wrap scroll jump: visual-line mapping via WrapIndex 2026-08-17 19:46:47 -04:00
wrap_index.go Fix word-wrap scroll jump: visual-line mapping via WrapIndex 2026-08-17 19:46:47 -04:00
wrap_mapping_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