Skip to main content

SyntaxRenderState

Struct SyntaxRenderState 

Source
pub struct SyntaxRenderState {
    pub syntax_handle: Option<Arc<SyntaxHandle>>,
    pub scroll: u32,
    pub viewport_height: u32,
    pub end_line_override: Option<u32>,
    pub fold_hash: u64,
    pub text_version: u64,
    pub inlay_hints: Arc<[InlayHintRow]>,
    pub inlay_version: u64,
    pub static_overlay_quads: Arc<ArcSwap<StaticOverlayQuads>>,
    pub doc_highlights: Arc<[Range]>,
    pub static_overlay_version: u64,
}
Expand description

Tree-sitter syntax inputs + static-overlay bucket cache.

Phase 5.8.AF.5 / Slice X2: split into two halves.

Inputs (syntax_handle, scroll, viewport_height, fold_hash, text_version, doc_highlights, static_overlay_version) are written by dispatch’s publish_render_state from current Editor state. The background overlay worker reads them via the published RenderState snapshot to decide whether to re-bucket.

Output (static_overlay_quads) is a nested Arc<ArcSwap<...>> so the worker can publish a fresh StaticOverlayQuads without going through publish_render_state. The outer RenderState Arc stays stable across a frame; the inner cell can be swapped at any time. Renderers read with render_state.syntax.static_overlay_quads.load() — wait-free.

display-line B4.2 (gut + rename): the dead visible_spans / visible_rows prepaint output cells were deleted; syntax colour now flows through the cells / DisplayMatrix substrate, and only the static-overlay bucket remains as a worker output here.

Goal #1 (“no parsing on the UI thread”) is enforced by this split: the overlay bucketing runs on the worker, not in any renderer’s per-frame body.

Fields§

§syntax_handle: Option<Arc<SyntaxHandle>>

Active document’s syntax handle. None when no language is attached (scratch buffer, plain text). The worker calls .snapshot() on this each tick to capture the current tree state for the highlight walk.

§scroll: u32

First visible line (the worker passes this as start to highlight_lines(start, end_line)).

§viewport_height: u32

Visible pane height in lines. The worker computes end_line = scroll + viewport_height (clamped by the snapshot’s line count) when Self::end_line_override is None.

§end_line_override: Option<u32>

Fold-aware highlight-window upper bound. Some(n) makes the worker walk [scroll, n) instead of the default [scroll, scroll + viewport_height). Set by the peer when closed folds collapse multiple buffer lines onto a single visible row, so a n_row viewport may need to highlight n_row + interior_fold_lines buffer lines for the post-fold tail to render with syntax styling. Slice X2.9 plumbing – before this the legacy Editor::refresh_highlights_window accepted end_line as an explicit argument; the X2 worker now reads it through the same render-state cell as every other input.

§fold_hash: u64

Caller-tracked signature of closed folds in the visible range. Folds change which physical lines are visible, so the cache key must include this to avoid serving stale spans across fold toggles.

§text_version: u64

Current document text version. The stale-snapshot HOLD (worker recompute path) compares the document’s version against the snapshot’s text_version() to decide whether the snapshot is still current or has fallen behind.

§inlay_hints: Arc<[InlayHintRow]>

Perf plan A.2 slice A.2b.1: active document’s flattened inlay-hint list, pre-gated by the buffer’s lsp-inlay-hint-mode enable-flag. Populated once per publish from Editor::lsp_inlay_hints_cache for the active document; empty when the mode is off, no LSP, or no hints have arrived yet.

Why on SyntaxRenderState and not LspRenderState: inlays are an INPUT to the cells / DisplayMatrix worker’s row composition (A.2b.2). The cells worker walks this list to splice inlay text into each composed row; downstream readers (GPUI’s active-pane prepaint) consume the woven rows. The raw per-buffer LSP cache stays on lsp.inlay_hints for the inactive-pane fallback path that flattens its own list. (display-line B4.2: the dead RowPrepaint cell that previously consumed this is gone.)

Coordinates: byte is a utf-8 offset against the active document’s line text; text already has padding_left / padding_right spaces baked in at the publish boundary.

§inlay_version: u64

Perf plan A.2 slice A.2b.2: content hash of inlay_hints. Paired with VisibleHighlightsKey::inlay_version so the worker invalidates its row cache when the inlay payload changes (arrivals, mode-gate flip, label edits). Stable across pure-scroll ticks (same payload → same hash → cache hit). Built by the publisher in the same pass that builds inlay_hints so the two stay aligned by construction.

§static_overlay_quads: Arc<ArcSwap<StaticOverlayQuads>>

Perf plan B.2: worker-published output cell for per-row pre-bucketed STATIC overlay quads (doc_highlight, all_matches, substitute). Same nested Arc<ArcSwap<...>> shape as visible_rows so the worker can swap a fresh bucket without rebuilding the outer RenderState. Inner Arc identity is the per-cell handle cloned from Editor::syntax_static_overlay_quads_cell at every publish.

Active-pane only — inactive panes keep the legacy per-frame bucket path in their renderer (the worker only pre-paints the active pane’s window). Cursor-coupled layers (visual_range, current_match) are merged in by the renderer at prepaint time; they’re cheap per-row (one range each) and would force a worker wake on every cursor blink if pushed off-thread.

§doc_highlights: Arc<[Range]>

Perf plan B.2: active document’s LSP document-highlight ranges, pre-converted from utf-16 columns to utf-8 byte offsets at publish time. The worker consumes this list directly when bucketing the DocHighlight layer instead of forcing the renderer to repeat the per-frame conversion against the snapshot text. Empty when the active buffer has no highlights or the LSP isn’t attached — matches the steady-state no-highlight path on a single cheap branch. Parallels Self::inlay_hints (A.2b.1).

§static_overlay_version: u64

Perf plan B.2: content hash of the static-overlay payload (doc_highlights + all_matches + substitute_matches). Paired with VisibleHighlightsKey::static_overlay_version so the worker invalidates its overlay bucket when any layer changes (search query bump, LSP response, substitute input edit). Independent from inlay_version so search churn doesn’t invalidate the row cache and vice versa. Built by the publisher from the same payload in static_overlay_state_version so the hash stays byte-aligned with the published list.

Trait Implementations§

Source§

impl Clone for SyntaxRenderState

Source§

fn clone(&self) -> SyntaxRenderState

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 SyntaxRenderState

Source§

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

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

impl Default for SyntaxRenderState

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