Skip to main content

Crate fc_model

Crate fc_model 

Source
Expand description

fc-model — shared text buffer primitives.

§Why a text buffer needs care

Almost every “simple” text editor bug is a UTF-8 bug. JavaScript string indices and Rust str indices are byte offsets; a user perceives character positions. For ASCII they coincide, which is why the bug survives development and appears in production for the first user typing an emoji or a combining accent.

Slicing a Rust str at a non-character-boundary index panics rather than producing garbage, and on wasm32-unknown-unknown that panic is an abort. So this crate owns every offset conversion, and the JS-facing API speaks UTF-16 code-unit offsets exclusively, because that is what JavaScript’s own indexing, selection APIs, and String.prototype.slice use. Converting once, here, is what keeps the rest of the workspace simple.

Structs§

Range16
A half-open range in UTF-16 code units.
TextBuffer
A UTF-8 text buffer with UTF-16-indexed access.