A simple, high performance text editor.
Tapping in the editor repositions the cursor, but it was never actually verified (the old unit test only checked in-bounds/no-panic). On-device verification found that on a large file scrolled deep, the cursor clamped to the bottom of the viewport regardless of tap position. Root cause: the tap handler computed the tap's text-local Y in content space (pt.Y - region.Y + full ScrollOffset) and passed it to SetCursorFromPoint, whose visualLine = y/lineHeight then produced a huge content-line number (e.g. 91,640). But the GlyphLayout is window-relative (layout.Y==0 is the top of the visible window), so the number far exceeded the window's line count and clamped to the last group (bottom line). The Phase 3 windowing refactor introduced the windowed layout without updating the tap handler. Fix: tapLocalY() converts the tap Y to window-relative space by adding only the sub-line remainder (ScrollOffset mod lineHeight), never the full scroll. Extracted as a named helper so it is unit-testable. Added two regression tests that fail on the pre-fix formula (cursor clamps to the bottom line) and pass on the fix. Verified on-device: taps now map linearly across the viewport. Also removed the per-tap/per-glyph log.Printf debug lines in SetCursorFromPoint. |
||
|---|---|---|
| .qwen | ||
| cmd/pad | ||
| doc | ||
| internal | ||
| .DS_Store | ||
| .gitignore | ||
| go.mod | ||
| go.sum | ||