• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moonbitlang / core / 5611 / 1
90%
main: 90%

Build:
DEFAULT BRANCH: main
Ran 28 Jul 2026 03:13AM UTC
Files 454
Run time 11s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

28 Jul 2026 03:12AM UTC coverage: 91.269% (-0.001%) from 91.27%
5611.1

push

github

web-flow
feat(diff): add Hunk structural accessors — the primitive for custom renderers (#3941)

Adds read-only structural access to a hunk, mirroring `Diff`'s own accessors:

  pub fn[T] Hunk::header(Self[T]) -> String            // "@@ -a,b +c,d @@"
  pub fn[T] Hunk::edits(Self[T]) -> ArrayView[Edit]
  pub fn[T] Hunk::old_view(Self[T]) -> ArrayView[T]
  pub fn[T] Hunk::new_view(Self[T]) -> ArrayView[T]

This cashes in the IOU accepted when `Hunk` became opaque: custom renderers
(terminal colors, HTML, side-by-side, word-diff) previously had to
re-implement `group`'s context-trimming semantics from `Diff::edits()`. With
structural access they are small user-side loops, and core stays 100%
presentation-free — no color flag, no style enum, no HTML.

A flattened per-line iterator (`lines() -> Iter2[LineKind, T]`) was prototyped
and rejected in design review: it loses edit-run structure (side-by-side and
word-diff renderers would re-cluster what core already knew), introduces a
second public vocabulary next to `Edit`, and a published `LineKind` enum could
never be retired — whereas a chunk-preserving convenience iterator can still
be added later compatibly. `header()` stays in core because unified-diff
numbering rules (1-based lines, single-line ranges without a length, empty
ranges anchored to the previous line) are canonical and easy to get subtly
wrong. The views are the complete inputs (not hunk-local), keeping a received
`Hunk` self-contained; `edits()` docs spell out which view each variant's
indices slice.

Validated from a third-party vantage point — the blackbox tests contain:
- a git-style ANSI renderer written purely against the public API,
  snapshot-tested;
- an HTML renderer with its own escaping, written to a file-based snapshot:
  a complete styled page at diff/__snapshot__/hunk.html, openable in a
  browser;
- a consistency test that structural reassembly agrees with `render()`;
- a README "Custom Renderers" recipe (compiled and snapshot-checked)... (continued)

15921 of 17444 relevant lines covered (91.27%)

188661.84 hits per line

Source Files on job 5611.1
  • Tree
  • List 454
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 5611
  • 58306543 on github
  • Prev Job for on main (#5606.1)
  • Next Job for on main (#5615.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc