Back to API Reference
Struct
GraphemeCountCache
sealed
Incremental grapheme-cluster count for a document — the per-keystroke companion of Count. The count is cached by Version; PredictCount evaluates a pending edit by re-segmenting only a boundary-safe window around it, and CommitEdit promotes that prediction to the new cached count when the applied EditShape matches. Any mutation the cache was not told about degrades to one full recount on the next query.
Remarks
Window edges are placed on boundaries that UAX #29 guarantees regardless of surrounding context (no RI-parity, ZWJ-emoji, or Indic-conjunct chain can cross them), so clusters outside the window are provably unaffected by the edit. When no safe edge exists within
MaxAnchorScan codepoints (a pathological run of joiners), the prediction falls back to per-part arithmetic and the commit invalidates instead.