Click target to expand/collaps element gets offset #5

Open
opened 2026-09-17 14:45:04 +00:00 by rs · 1 comment
Owner

Bug, Once the output history reaches a multi screen size the click area to expand/collapse an element drifts away from the element displayed position itself.

Bug, Once the output history reaches a multi screen size the click area to expand/collapse an element drifts away from the element displayed position itself.
Author
Owner

Fixed on main in b7214ea, released as v0.10.2.

Root cause: commit 8bd1dc8 wrapped the concatenated output with fitOutputWidth (ansi.Hardwrap) so over-wide lines are not truncated. The wrap inserts real newlines, but the entry coordinate math still measured entries with renderedHeight on the unwrapped text (entryAtLine, scrollToEntry, clickToggles). Each wrapped line above a block added an uncounted viewport row, so the click target drifted further the longer the output history.

Fix: refreshViewport wraps each entry and stores the wrapped row count in entry.height; the hit-test/scroll code uses it. e.rendered stays unwrapped so resizing re-wraps entries that are not re-rendered, and the streaming markdown tail is wrapped explicitly. This fixes mouse collapse/expand toggling, border hit-testing and [/] block scrolling together.

Tests: TestClickTogglesAfterWrappedOutput (verified failing before the fix) and TestEntryHeightsMatchViewportContent; gofmt, go vet ./..., go test -count=1 ./... pass.

Leaving open for verification.

Fixed on `main` in `b7214ea`, released as `v0.10.2`. **Root cause:** commit `8bd1dc8` wrapped the concatenated output with `fitOutputWidth` (`ansi.Hardwrap`) so over-wide lines are not truncated. The wrap inserts real newlines, but the entry coordinate math still measured entries with `renderedHeight` on the unwrapped text (`entryAtLine`, `scrollToEntry`, `clickToggles`). Each wrapped line above a block added an uncounted viewport row, so the click target drifted further the longer the output history. **Fix:** `refreshViewport` wraps each entry and stores the wrapped row count in `entry.height`; the hit-test/scroll code uses it. `e.rendered` stays unwrapped so resizing re-wraps entries that are not re-rendered, and the streaming markdown tail is wrapped explicitly. This fixes mouse collapse/expand toggling, border hit-testing and `[`/`]` block scrolling together. **Tests:** `TestClickTogglesAfterWrappedOutput` (verified failing before the fix) and `TestEntryHeightsMatchViewportContent`; `gofmt`, `go vet ./...`, `go test -count=1 ./...` pass. Leaving open for verification.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rs/harness#5
No description provided.