Skip to main content

CellChunk

Struct CellChunk 

Source
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):

  • rows is sorted ascending by source_line.
  • Folded source lines do not appear; row count is post-fold.
  • start_source_line is 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 from rows.
  • version is the MatrixVersion snapshot 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: MatrixVersion

Implementations§

Source§

impl CellChunk

Source

pub fn new( start_source_line: u32, rows: impl Into<Arc<[CellRow]>>, version: MatrixVersion, ) -> Self

Construct a chunk. S2 is the production caller.

Source

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.

Source

pub fn row_count(&self) -> u32

Number of matrix rows this chunk contributes (post-fold).

Source

pub fn is_empty(&self) -> bool

true when no rows are present (fully-folded range or freshly-allocated empty chunk).

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for CellChunk

Source§

fn clone(&self) -> CellChunk

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CellChunk

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more