pub struct CellChunk {
pub start_source_line: u32,
pub rows: Arc<[CellRow]>,
pub version: MatrixVersion,
}Expand description
Contiguous range of matrix rows covering a slice of the buffer.
Invariants (S2 enforces; S1 documents):
rowsis sorted ascending bysource_line.- Folded source lines do not appear; row count is post-fold.
start_source_lineis the FIRST source line that could appear in this chunk’s range. The chunk’s range is[start_source_line, start_source_line + chunk_size)in logical (pre-fold) source-line space. Some of those source lines may be folded and therefore absent fromrows.versionis theMatrixVersionsnapshot captured at build time. Cell-builder compares against current RenderState version to decide if this chunk needs rebuild.
Fields§
§start_source_line: u32§rows: Arc<[CellRow]>§version: MatrixVersionImplementations§
Source§impl CellChunk
impl CellChunk
Sourcepub fn new(
start_source_line: u32,
rows: impl Into<Arc<[CellRow]>>,
version: MatrixVersion,
) -> Self
pub fn new( start_source_line: u32, rows: impl Into<Arc<[CellRow]>>, version: MatrixVersion, ) -> Self
Construct a chunk. S2 is the production caller.
Sourcepub fn empty(start_source_line: u32, version: MatrixVersion) -> Self
pub fn empty(start_source_line: u32, version: MatrixVersion) -> Self
Empty chunk anchored at start_source_line. Used when the
covered source-line range is entirely folded (no visible
rows) or as a placeholder during incremental build.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
true when no rows are present (fully-folded range or
freshly-allocated empty chunk).
Sourcepub fn row_at_source_line(&self, target: u32) -> Option<&CellRow>
pub fn row_at_source_line(&self, target: u32) -> Option<&CellRow>
Returns the row whose source_line equals target, if it
is present in this chunk (i.e. not folded).
Binary search on source_line; O(log N) for the typical
128-row chunk. Returns None if target is folded or
outside the chunk’s range.
Sourcepub fn shifted_by(&self, line_delta: i32, new_version: MatrixVersion) -> Self
pub fn shifted_by(&self, line_delta: i32, new_version: MatrixVersion) -> Self
Clone-with-shifted-line. Produces a new chunk whose
start_source_line and every contained row’s source_line
are shifted by line_delta. Cell payloads are shared (one
Arc refcount bump per row’s cells + inlay_offsets);
no rope reads, no theme work, no syntax walk.
Used by the cell-builder’s incremental rebuild path
(S2.4.b) for chunks past a single-line edit’s affected
range — their cell content is unchanged, only their
logical line position shifts. new_version stamps the
chunk with the publisher’s current matrix version so the
renderer can compare against the new matrix’s version.
line_delta may be negative (deletions shift downstream
lines down). The shifted source_line saturates at 0 if
the caller passes an unreasonably-negative delta; callers
in S2.4.b only ever invoke this on chunks past the edit’s
affected range, so the saturating path is defensive only.