Skip to main content

compose_header_rows

Function compose_header_rows 

Source
pub fn compose_header_rows(
    excerpts: &[Excerpt],
    grouping: FoldGrouping,
    render_cells: impl FnMut(&Excerpt) -> Arc<[Cell]>,
) -> Vec<VirtualRow>
Expand description

Pure function from excerpt list → header virtual rows, under grouping.

FoldGrouping::SourceFile emits ONE row per distinct consecutive source — when N consecutive excerpts share excerpt.source, only the first contributes a header, anchored Above its first composed line.

K.4.6 follow-up (2026-06-02): pre-fix this emitted one row per excerpt unconditionally, which broke “1 header per file” for providers like search that emit multiple excerpts per file (one per hit cluster). The dedup happens here in substrate, not in providers.

FoldGrouping::HeaderRuns groups by the header TITLE instead, with exactly the rule HeaderGroupFoldProvider already folds by:

  • a non-empty title differing from the current group’s starts a group;
  • a non-empty title equal to it continues it;
  • an empty title continues it — that is what “I belong to the group above” has always meant in this tree.

OA.2. The agenda needs this because it groups by DATE and its rows interleave files by design, so a file boundary is not a group boundary there. It gave the first row of a date group the label and the rest an empty title, on the documented assumption that an empty title renders no header — but source-run dedup emitted one at every file change, and header_cells renders a titleless, pathless header as [untitled]. One date group drawn from two files rendered ["2026-08-31 Mon (today)", "[untitled]", "[untitled]"].

Not the default, and that is not timidity: lattice-lsp’s references view titles each excerpt with its LINE NUMBER, so consecutive excerpts from one file carry different titles and title-runs would give it a header per reference instead of per file.