Expand description
Fold ranges for magit-status inline expansions — the ENTRY level.
An overlay [FoldSource] that reads live state on every
compute_folds() call rather than caching stale line numbers, so
it never desyncs from concurrent edits. It emits one fold per
expanded entry (file / stash / commit), spanning the entry’s header
row through the end of its inserted patch — so folding “this entry”
hides the whole thing.
MG.45 moved the levels BELOW that out. File and hunk folds now
come from [crate::hunk_fold_source::MagitHunkFoldSource], which
magit-hunk-mode registers on every buffer that renders a diff.
Two reasons, and the second is the one that mattered:
- Only magit-status had a fold source, so the commit, diff, revision and stash-show buffers had no diff-aware folds at all.
- This source can only see ONE expansion’s rows. A commit or
stash entry expands to a MULTI-file patch (
git show,stash show -p), which needs a file level between entry and hunk — and every file’s hunks were landing as siblings directly under the entry instead.
The two sources compose by range containment, the way the fold engine expresses nesting everywhere else, so an expanded commit folds as entry ▸ file ▸ hunk with neither source knowing about the other.
Registered by MagitStatusMode::on_activate via
FoldOverlayServiceHandle; MagitStatusGuard::drop removes it
(same Drop-based lifecycle DiffModeGuard and
MultibufferModeGuard use).
Structs§
Constants§
- MAGIT_
STATUS_ FOLD_ NAMESPACE - Namespace for per-buffer magit-status fold-source ids, OR’d with the buffer’s id so simultaneous magit-status buffers (unusual, but not disallowed) register distinct overlay ids.