Commit 2c6d4dd
fix(render): preserve past-EOF tokenisation in segmented build_base_tokens
Phase 5b's segmentation introduced two early-exit paths that broke
tokenisation when `top_byte` lands at or past `buffer.len()`:
- A `cursor >= buffer_len` outer-loop break that returned an empty
token vector. The original code instead let `LineIterator::new`
clamp `top_byte` internally and use a backward scan to locate the
line containing the (clamped) position, so a viewport scrolled past
EOF on a single very long wrapped line still produced tokens for
the final source line.
- An inner-loop `line_start >= segment_end` break that fired even
when `segment_end` was just `buffer_len` (no fold ahead). For an
EOF-empty trailing line (e.g. buffer ends in `\n`), `LineIterator`
emits a `(buffer_len, "")` line that was being dropped.
Both checks now only trigger when there's an actual upcoming fold.
With an empty `fold_skip`, `LineIterator` runs to natural exhaustion
— matching the pre-Phase-5b behaviour exactly.
Reproduced and verified by `test_mouse_wheel_scrolls_wrapped_content`
(60-col viewport, single 1600-char line, 20 mouse-wheel scrolls):
viewport now correctly shows later wrapped sections after scroll.
https://claude.ai/code/session_014WZ8ca3tvhrQ9NcVHrV53d1 parent e1492ac commit 2c6d4dd
1 file changed
Lines changed: 24 additions & 15 deletions
Lines changed: 24 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
43 | | - | |
| 47 | + | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
| |||
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
52 | | - | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
67 | | - | |
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
75 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
76 | 85 | | |
77 | 86 | | |
78 | 87 | | |
| |||
183 | 192 | | |
184 | 193 | | |
185 | 194 | | |
186 | | - | |
| 195 | + | |
187 | 196 | | |
188 | 197 | | |
189 | 198 | | |
| |||
0 commit comments