Skip to main content

CellsRenderState

Struct CellsRenderState 

Source
pub struct CellsRenderState {
Show 18 fields pub matrix: Arc<ArcSwap<CellMatrix>>, pub version: MatrixVersion, pub snapshot: Option<Arc<DocumentSnapshot>>, pub syntax_handle: Option<Arc<SyntaxHandle>>, pub inlay_hints: Arc<[InlayHintRow]>, pub folds: Arc<[Fold]>, pub viewport_height: u32, pub foldenable: bool, pub last_edit: Option<EditDelta>, pub resolved_theme: Arc<ResolvedTheme>, pub theme_ids: BuiltinElementIds, pub whitespace: WhitespaceConfig, pub panes: Arc<[PaneCellsInputs]>, pub pane_matrices: Arc<HashMap<PaneId, Arc<ArcSwap<CellMatrix>>>>, pub display_matrix: Arc<ArcSwap<DisplayMatrix>>, pub display_pane_matrices: Arc<HashMap<PaneId, Arc<ArcSwap<DisplayMatrix>>>>, pub pane_indent_guides: Arc<HashMap<PaneId, Arc<ArcSwap<IndentGuides>>>>, pub pane_sticky_context: Arc<HashMap<PaneId, Arc<ArcSwap<StickyContext>>>>,
}
Expand description

Cell-grid renderer substrate state. Mirror of SyntaxRenderState in shape (wait-free output cell + read inputs); replaces the per-frame shape_line path for code-class buffers.

S2.1: only the plumbing is in place — matrix is published but stays empty until S2.2 spawns the cell-builder worker that will write to it. The other fields are populated from current Editor state by build_render_state so the worker has its full input set the moment it lands.

Anchor: docs/dev/architecture/cell-grid-renderer.md.

Fields§

§matrix: Arc<ArcSwap<CellMatrix>>

Worker-published output cell. Inner Arc identity stays stable across publishes (cloned from Editor::cells_matrix_cell) so the worker’s writes survive subsequent publishes — same stability pattern as [SyntaxRenderState::visible_spans].

§version: MatrixVersion

Aggregate version stamp of the inputs below. Worker compares against the published matrix’s lattice_cells::CellMatrix::version to decide rebuild — see lattice_cells::MatrixVersion::differs_from. Folds text_version, syntax-derived stamp, inlay_hints content hash, folds content hash, and theme version into one comparison value.

§snapshot: Option<Arc<DocumentSnapshot>>

Active document snapshot. The cell-builder walks this line-by-line. None when no document is active (initial boot or between buffer switches). Cloned by reference from the active RopeDocumentHandle.snapshot() at publish time.

§syntax_handle: Option<Arc<SyntaxHandle>>

Active buffer’s syntax handle. Consumed by S2.3 cell construction to resolve per-cell foreground colour from the syntax span set. None when no language is attached — cells fall back to the theme default fg.

§inlay_hints: Arc<[InlayHintRow]>

Pre-flattened inlay hints for the active buffer. Same payload as SyntaxRenderState::inlay_hints; carried here so the cell-builder can splice inlay text into cells without re-reading the LSP cache (S2.3).

§folds: Arc<[Fold]>

Active buffer’s fold ranges. Consumed by S2.3 for row elision (folded source lines do not produce matrix rows).

§viewport_height: u32

Visible pane height in matrix rows. S2.4 reads this to pick chunk_size = 2 × viewport_height when above the whole-doc-mode threshold.

§foldenable: bool

:set foldenable for the active buffer. The cell-builder feeds this into crate::folds::FoldIndex::from_folds so elision predicates collapse to false when folding is off — zi then yields the unfolded matrix without a separate code path. Folded into lattice_cells::MatrixVersion::folds at publish time so toggling foldenable invalidates the matrix.

§last_edit: Option<EditDelta>

S2.4.b (2026-05-26): single-edit delta covering the bump from the previous publish’s text_version to this publish’s text_version. Some(d) when exactly one apply_edit_blocking happened since the last build and the worker can take the incremental rebuild path; None otherwise (no edit, batch, undo / redo, multi-edit coalescing) — in which case the worker conservatively full-rebuilds. Sourced from Editor::last_edit_for_cells via take() at build_render_state time, so subsequent publishes without further edits see None.

§resolved_theme: Arc<ResolvedTheme>

T.5 (theme-system): the resolved read table + builtin ids the cell-builder uses to resolve each span’s lattice_syntax::Style → resolved.get(syntax_element_id(ids, s)) (O(1) array index). Snapshotted at publish. T.6.t deleted the flat host Theme field that used to ride alongside it; the matrix invalidation key (MatrixVersion::theme) is now ResolvedTheme::version(), set at build_render_state time, so a palette change still rebuilds the matrix with fresh colours.

§theme_ids: BuiltinElementIds§whitespace: WhitespaceConfig

2026-05-27: display.whitespace.* snapshot. Worker substitutes whitespace bytes with marker glyphs + WS_MARKER flag when show is true. A hash of this struct is folded into lattice_cells::MatrixVersion::whitespace at publish time so any :set of a whitespace option invalidates the matrix and triggers a rebuild.

§panes: Arc<[PaneCellsInputs]>

D.4.d.1.a (2026-05-29): one entry per visible Document pane. Populated by publish_render_state from pane_tree.leaves(); non-Document leaves are skipped.

D.4.d.1.b consumes this slice in crate::cells_worker::recompute — each entry’s matrix is the per-buffer registry cell the worker writes through. The active pane’s entry shares Arc identity with Self::matrix so today’s renderer read path keeps landing on the worker’s writes for the active pane; Self::pane_matrices + Self::matrix_for_pane are the per-pane read surface renderers can use to find a non-active pane’s matrix without iterating panes.

§pane_matrices: Arc<HashMap<PaneId, Arc<ArcSwap<CellMatrix>>>>

D.4.d.1.c (2026-05-29): PaneId → matrix lookup derived from Self::panes at publish time so renderers can find a pane’s matrix by id without scanning the panes slice. One entry per visible Document leaf; non-Document panes are absent (the renderer’s per-kind dispatch already knows not to consult cells for those).

Use Self::matrix_for_pane for the read; direct access to the map is fine when batching multiple lookups.

§display_matrix: Arc<ArcSwap<DisplayMatrix>>

B2.1 (2026-06-04): active-pane per-line display matrix. Clone of Editor::display_matrix_cell (stable Arc identity so the worker’s writes survive subsequent publishes) — the per-line analogue of Self::matrix. Empty until the B2.2 worker build path writes through it. See docs/dev/architecture/display-line.md.

§display_pane_matrices: Arc<HashMap<PaneId, Arc<ArcSwap<DisplayMatrix>>>>

B2.1 (2026-06-04): PaneId → display matrix lookup, the per-line analogue of Self::pane_matrices. One entry per visible Document leaf; derived at publish time from Self::panes. Read via Self::display_matrix_for_pane.

§pane_indent_guides: Arc<HashMap<PaneId, Arc<ArcSwap<IndentGuides>>>>

IG.2 (2026-08-16): PaneId → indentation guides, the peer of Self::display_pane_matrices and derived from the same panes list at publish time. Read via Self::indent_guides_for_pane.

§pane_sticky_context: Arc<HashMap<PaneId, Arc<ArcSwap<StickyContext>>>>

TC.3b: PaneId → sticky context, the peer of Self::pane_indent_guides, derived from the same panes list at publish time. Read via Self::sticky_context_for_pane.

Implementations§

Source§

impl CellsRenderState

Source

pub fn display_matrix_for_pane( &self, pane_id: PaneId, ) -> Option<&Arc<ArcSwap<DisplayMatrix>>>

B2.1 (2026-06-04): look up the per-line display matrix for pane_id. None when the pane is not a Document leaf (same semantics as Self::matrix_for_pane).

Source

pub fn indent_guides_for_pane( &self, pane_id: PaneId, ) -> Option<&Arc<ArcSwap<IndentGuides>>>

IG.2 (2026-08-16): the indentation-guide layer for pane_id. None for a pane with no display matrix (non-Document leaves skip the cells path), which is the correct “no guides” answer.

Source

pub fn sticky_context_for_pane( &self, pane_id: PaneId, ) -> Option<&Arc<ArcSwap<StickyContext>>>

TC.3b: look up the pinned context strip for pane_id. None when the pane is not a document-backed leaf (it then pins nothing).

Source

pub fn matrix_for_pane( &self, pane_id: PaneId, ) -> Option<&Arc<ArcSwap<CellMatrix>>>

D.4.d.1.c: look up the cell matrix for pane_id. Returns None when the pane is not a Document leaf (file tree / help / messages / oil / terminal panes skip the cells path entirely — see crate::dispatch::Editor::build_cells_panes).

Source

pub fn whitespace_version_for_pane(&self, pane_id: PaneId) -> u64

The current whitespace-axis stamp for pane_id — what a matrix built right now would carry. A renderer compares it against the matrix it is about to paint from (lattice_cells::MatrixVersion::whitespace); a mismatch means the cells were emitted under a different display.whitespace.* configuration and their decoration is wrong until the worker rebuilds.

Falls back to the top-level aggregate when the pane has no entry (non-Document leaf, or a publish gap) — that stamp is computed from the same option fields, so the comparison stays meaningful rather than silently passing.

Source

pub fn wrap_width_for_pane(&self, pane_id: PaneId) -> u32

CV.4: the soft-wrap column width for pane_id derived from live published geometry — viewport_width minus the gutter reservation, or 0 when the pane does not wrap.

This is the value the cells worker will stamp onto the matrix as wrap_width, computed from the same two published inputs, and therefore available a frame before the worker runs. A renderer that reads the matrix’s stamp instead paints unwrapped until the worker catches up: on a freshly opened file, right after a resize, and on the keystroke that ran :set wrap. Reading it here keeps both peers and the host’s scroll clamp on one number.

0 for a pane with no published entry (non-Document leaves skip the cells path), which is the correct “no wrapping” answer for them.

Trait Implementations§

Source§

impl Clone for CellsRenderState

Source§

fn clone(&self) -> CellsRenderState

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 CellsRenderState

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for CellsRenderState

Source§

fn default() -> Self

Returns the “default value” for a type. 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoMaybeUndefined<T> for T

§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
§

impl<T> IntoOption<T> for T

§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Pointer = u32

§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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