Skip to content

EditorTokenStore

The document’s syntax tokens: packed offsets and palette ids, sorted by start, immutable.

An edit shifts every token after it. Stores share their arrays and keep that shift per segment, so deriving a store costs the edited tokens, not the document.

readonly derivedFrom: EditorTokenStoreOrigin | null


readonly length: number


readonly monotonicEnd: boolean


readonly nonOverlapping: boolean


readonly revision: number


readonly styles: readonly EditorTokenStyle[]

applyPatch(patch): EditorTokenStore

Re-tokenized lines spliced in. Patch styles join the palette by value.

PackedEditorTokenPatch

EditorTokenStore


changedRangeTo(next): object

The smallest replacement that turns this store into next: tokens [start, start + deleteCount) here become [start, insertEnd) there. Segments the two share are skipped, not compared.

EditorTokenStore

object

readonly deleteCount: number

readonly insertEnd: number

readonly start: number


endAt(index): number

number

number


equals(other): boolean

True when both hold the same tokens. Segments the two share are skipped, not compared.

EditorTokenStore

boolean


firstEndingAfter(offset, endIndex?): number

First index below endIndex whose running maximum end is past offset.

number

number

number


firstEndingAtOrAfter(offset, endIndex?): number

number

number

number


firstStartingAfter(offset): number

number

number


firstStartingAtOrAfter(offset): number

number

number


forEachInRange(from, to, visit): void

number

number

(start, end, styleId, index) => void

void


replaceOffsetRange(startOffset, endOffset, tokens): EditorTokenStore

A fresh answer for [startOffset, endOffset); every token reaching into it is replaced.

number

number

EditorTokenStore

EditorTokenStore


replaceRange(first, last, inserted, options): EditorTokenStore

This store with tokens [first, last) replaced by inserted and every later token shifted. A projection through an edit and a highlighter’s re-tokenized lines are both this operation.

number

number

EditorTokenRun

EditorTokenStoreReplaceOptions

EditorTokenStore


startAt(index): number

number

number


styleAt(index): EditorTokenStyle

number

EditorTokenStyle


styleIdAt(index): number

number

number


stylesEqual(other): boolean

True when token i has the same style in both, whatever its offsets.

EditorTokenStore

boolean


tokenAt(index): EditorToken

number

EditorToken


toPacked(): PackedEditorTokens

One contiguous copy, for a worker transfer or a JSON snapshot. Costs the document.

PackedEditorTokens


toTokens(from?, to?): EditorToken[]

Object tokens for [from, to). The whole-document form is for exports, never for an edit.

number

number

EditorToken[]


static empty(): EditorTokenStore

EditorTokenStore


static fromPacked(packed): EditorTokenStore

Takes ownership of the packed arrays; nothing may write to them afterwards.

PackedEditorTokens

EditorTokenStore


static fromTokens(tokens): EditorTokenStore

The boundary for hosts that build tokens by hand; costs the input, not the document.

readonly EditorToken[]

EditorTokenStore


static inspectRetention(stores): EditorTokenStoreRetentionSnapshot

Iterable<EditorTokenStore>

EditorTokenStoreRetentionSnapshot