#274: align editor line numbers with wrapped text rows #276

Merged
fen merged 1 commits from fix-274 into dev 2026-09-17 23:56:35 +00:00
Collaborator

Fix attempt 1. Ref #274.

With wrap on in the editor, a logical line occupies several visual rows in the textarea but the gutter rendered one number per logical line, so every number after the first wrapped line drifted off its text (the paste view fixed the same bug in #167; the editor gutter was never updated).

Fix: measure the wrapped row count per logical line with a hidden mirror div sharing the editor font metrics and wrapping rules, render one .gutline block per visual row with the number on the first row of its logical line, re-measure on input / wrap toggle / resize. Wrap off keeps the plain one-number-per-line path.

Verified locally: gutter scrollHeight == textarea scrollHeight (zero diff) with wrap on at 1400x900 and 375x812; wrap off unchanged; go build/test pass.

Fix attempt 1. Ref #274. With wrap on in the editor, a logical line occupies several visual rows in the textarea but the gutter rendered one number per logical line, so every number after the first wrapped line drifted off its text (the paste view fixed the same bug in #167; the editor gutter was never updated). Fix: measure the wrapped row count per logical line with a hidden mirror div sharing the editor font metrics and wrapping rules, render one .gutline block per visual row with the number on the first row of its logical line, re-measure on input / wrap toggle / resize. Wrap off keeps the plain one-number-per-line path. Verified locally: gutter scrollHeight == textarea scrollHeight (zero diff) with wrap on at 1400x900 and 375x812; wrap off unchanged; go build/test pass.
fen added 1 commit 2026-09-17 23:50:24 +00:00
#274: align editor line numbers with wrapped text rows
CI / docker (pull_request) Skipped
CI / test (pull_request) Successful in 24s
7fdb3ee61c
With wrap on, a logical line occupies several visual rows in the textarea
but the gutter showed one number per logical line, so every number after
the first wrapped line drifted off its text (the paste view fixed this in
#167; the editor gutter did not). Measure the wrapped row count per logical
line with a hidden mirror div sharing the editor's font and wrapping rules,
and render one .gutline block per visual row with the number on the first
row of its logical line. Re-measure on input, wrap toggle and resize.
Verified: gutter scrollHeight == textarea scrollHeight with zero diff at
1400x900 and 375x812, wrap on and off.
fen merged commit 70b06db192 into dev 2026-09-17 23:56:35 +00:00
Sign in to join this conversation.