Unified buffer-line-to-display-row mapping.
Merges per-window folds (FoldMap), per-buffer decoration folds
(Decorations.FoldRegion), virtual lines (Decorations.VirtualText
with :above/:below placement), and block decorations into a single
authoritative mapping.
The DisplayMap is the single source of truth for translating between
buffer line numbers and screen row positions. It replaces
FoldMap.VisibleLines.compute/4 in the render pipeline.
Design
The DisplayMap is a pure data structure built once per frame from:
- Per-window
FoldMapfolds (code folds, per-window) - Per-buffer decoration folds (closed fold regions from
Decorations) - Virtual lines from decorations (
:above/:below) - Block decorations (custom-rendered lines between buffer lines)
The map produces a list of entry() tuples describing what to render
at each display row, compatible with the existing content rendering
pipeline.
Summary
Functions
Computes the display map for a viewport.
Returns the display row for a buffer line, or nil if hidden.
Returns true when folds, virtual lines, or block decorations require a display map.
Returns the entry list for the content renderer.
Types
@type entry() :: {non_neg_integer(), :normal} | {non_neg_integer(), {:fold_start, pos_integer()}} | {non_neg_integer(), {:decoration_fold, Minga.Core.Decorations.FoldRegion.t()}} | {non_neg_integer(), {:virtual_line, Minga.Core.Decorations.VirtualText.t()}} | {non_neg_integer(), {:block, Minga.Core.Decorations.BlockDecoration.t(), non_neg_integer()}}
What to render at a display row.
{buf_line, :normal}— render the buffer line normally{buf_line, {:fold_start, hidden_count}}— render with fold summary{buf_line, {:decoration_fold, fold_region}}— render with custom placeholder{buf_line, {:virtual_line, virtual_text}}— render a virtual line (no buffer line){buf_line, {:block, block_decoration, line_index}}— render a block decoration row
@type t() :: %MingaEditor.DisplayMap{entries: [entry()]}
The computed display map for a viewport.
Functions
@spec compute( MingaEditor.FoldMap.t(), Minga.Core.Decorations.t(), non_neg_integer(), pos_integer(), non_neg_integer(), pos_integer() ) :: t() | nil
Computes the display map for a viewport.
Returns nil when there are no folds, decoration folds, virtual lines,
or block decorations, signaling the caller to use the faster sequential path.
Arguments
fold_map— per-windowFoldMap(code folds)decorations— per-bufferDecorationsfirst_buf_line— first buffer line to display (from viewport scroll)visible_rows— number of screen rows availabletotal_lines— total lines in the buffercontent_width— available width for block decoration render callbacks (default 80)
@spec display_row_for_buf_line(t(), non_neg_integer()) :: non_neg_integer() | nil
Returns the display row for a buffer line, or nil if hidden.
@spec required?(MingaEditor.FoldMap.t(), Minga.Core.Decorations.t()) :: boolean()
Returns true when folds, virtual lines, or block decorations require a display map.
Returns the entry list for the content renderer.