Pad/internal/editor
Greg Pomerantz 3bc3ed3530 editor: add window base offset to tap/cursor positioning
The GlyphLayout is shaped from the visible window alone, so its
ByteOffsets are relative to the window start (IMEWindowStartByte). But
SetCursorFromPoint, HandleHome, HandleEnd and HandleVerticalCursorMove
treated them as absolute file offsets. On a large file scrolled deep, the
cursor was set to a window-relative offset (near the file start), so the
next EditorLayout computed visibleCursorPos = CursorPosition - start as a
small/negative value and the IME selection snapped to the window top
(regardless of where the user tapped).

Add glyphBase() and convert at the four cursor boundaries: subtract the
base before searching the window-relative offsets, add it back before
storing the absolute CursorPosition. For small files (window == whole
file) the base is 0 and the change is a no-op.

Add TestTapToPosition_WindowBaseOffset, a regression test that sets a
non-zero IMEWindowStartByte and asserts the cursor lands at base + window
byte (fails on the pre-fix window-relative assignment).

Verified on-device: with a 6 MB file scrolled to ~line 1200, a tap now
places the cursor on the tapped line (typed text lands ~16 lines below the
window top), where before it always landed on the window top.
2026-08-16 20:59:06 -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_test.go editor: fix viewport-on-open, chunked-buffer drift, add size guard (Phase 3 code) 2026-08-16 10:35:10 -04:00
chunked_buffer.go editor: fix whole-file shaper leak + LineIndex mismatch (Phase 3) 2026-08-16 12:16:52 -04:00
cursor_test.go editor: add window base offset to tap/cursor positioning 2026-08-16 20:59:06 -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 editor: fix viewport-on-open, chunked-buffer drift, add size guard (Phase 3 code) 2026-08-16 10:35:10 -04:00
filename_test.go feat: implement atomic writes for filesystem backend 2026-06-04 18:01:51 -04:00
frame.go Make state single-owner and stabilize race detector 2026-08-16 01:32:27 -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
logic.go chore: remove per-event debug logging from the normal path 2026-08-16 20:58:49 -04:00
mock_setup.go Integrate real filesystem with interface abstraction 2026-06-04 16:19:38 -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
state.go editor: add window base offset to tap/cursor positioning 2026-08-16 20:59:06 -04:00