pmacs/pmacs-gpu
Levi Neuwirth e547a90e37 fix(gpu): stop the minimap dividing by zero on an all-blank slab
`dominant_line_shape` averages only the lines in a bucket that have
content, then guarded the result with `bool::then_some`. `then_some`
takes its argument by value, so the `MinimapLineShape` literal --- and
with it `indent_sum / count` --- is evaluated before the `count > 0`
guard is ever consulted. When a bucket holds no contentful lines the
division panics and takes the GPU frontend down.

This is reachable in ordinary use, not at an edge: the bucketing branch
runs whenever a file has more lines than the minimap has pixel rows, and
it is exactly then that a run of blank lines can fill a whole downsampled
row. A whitespace-only line counts as blank too --- `minimap_line_shape`
subtracts the indent from the total, so `content_cols` is zero.

Switch to `bool::then`, which defers the body into a closure so the zero
case short-circuits to `None`. The call site already treats `None` as
"draw no stroke for this row", so no other change is needed.

Three tests, two of which fail against the previous line:

  * a 10,000-line all-blank file driven through `minimap_rects`, which
    reproduces the original panic through the real downsampling path;
  * `dominant_line_shape` on an empty bucket;
  * a mixed bucket, asserting the average still ignores blank lines ---
    a companion guard so the fix cannot regress into counting the whole
    slice.

A comment records why this must not be "simplified" back: clippy's
`unnecessary_lazy_evaluations` pushes in precisely the wrong direction
here, and does not fire on a body that can panic.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-25 09:42:25 -04:00
..
fonts fix(font): close stage-2 GPU behavioral findings 2026-07-18 15:29:25 +01:00
src fix(gpu): stop the minimap dividing by zero on an all-blank slab 2026-07-25 09:42:25 -04:00
Cargo.toml Address GPU invocation review findings 2026-07-23 11:50:33 -04:00