Expand description
MG.14 — the sticky headerline every magit buffer carries.
What it answers. Each magit view is a slab of git output whose
identity lives outside the text: *magit:diff* does not say which
scope it diffed, *magit:blame:x.rs* does not say which revision
it walked back to, the status buffer never showed the branch at
all (SectionIndex::branch_status_line was written for it and
never called). The headerline is the one row that answers “what am
I looking at?” without re-deriving it from the body.
One provider, every view. There is exactly one [Headerline]
impl here, and the per-view difference is data: a Vec<Field>,
each field a string plus a FieldStyle naming its git role. No
match buffer_kind, no per-kind impl — adding a view means adding
a field-builder function, not a branch.
No work per tick. The cells worker calls [Headerline::version]
every tick and [Headerline::render] only when it advanced.
MagitHeaderline::set compares before it bumps, so a refresh that
finds the same branch and the same counts costs one comparison and
no repaint (paramount goal #1). Fields are produced by the SAME
blocking builder that produces the buffer’s text — activation and
gr alike — so the header never costs a git round-trip of its own.
Theme-live. The row resolves its colours inside render() and
folds the theme’s resolved version into its own, so :colorscheme
repaints the header instead of leaving it on the previous palette’s
colours. The two headerlines that shipped before this one
(compilation, ai-conversation) capture u32s at activation and go
stale; this is the better shape and the cost is one uncontended
read-lock per tick.
Design anchor: docs/dev/architecture/headerline.md, slice
docs/dev/operations/slice-plans/magit.md §MG.14.
Structs§
- Field
- One coloured run in the header row.
- Headerline
Registration - Removes the buffer’s headerline provider when the mode deactivates.
- Magit
Headerline - The one [
Headerline] impl behind every magit buffer’s header row.
Enums§
- Field
Style - The git role a header field plays. Maps to a theme element, which
is what gives the row its identity-by-colour (the compact format
carries no
Head:-style labels).
Constants§
- MAGIT_
HEADERLINE_ PROVIDER_ ID - Provider id tag for magit’s headerline. One per buffer scope, so a single constant covers every view — a magit buffer has exactly one major mode and therefore exactly one header.
Functions§
- install
- Build a headerline for
bufferand register it as a virtual-row provider. Returns the handle the mode keeps (tosetfields as its data lands) and the registration whose drop tears the row down.
Type Aliases§
- Magit
Headerline Handle - Cheap-clone handle. The mode keeps one in its per-buffer state so
every refresh path can re-
setthe row; the registered provider holds another reference to the same allocation.