An Editor always owns a MultiBuffer. For normal single-file editing, the MultiBuffer wraps exactly one Buffer with a single excerpt covering the whole file.
Every edit to text invalidates the syntax tree. A background_spawn task runs SyntaxMap::reparse() and then drops its result back onto the foreground by updating the Buffer entity and calling cx.notify().
An immutable, point-in-time copy of all buffer state. EditorElement takes a snapshot once per frame and uses it for rendering — changes during the frame don't affect what's painted. The snapshot owns the parsed tree and all diagnostics.
Use-cases for MultiBuffer with multiple excerpts: search results (grep matches from many files shown inline), go-to-definition peek panel, and multi-file refactor previews.
Languages are registered in LanguageRegistry. When a buffer's file path changes or content hints at a language (shebangs, magic bytes), the registry detects and assigns the right Language.
TextBuffer records the op and emits a range of changed bytes.SyntaxMap::did_edit(), marking the affected tree nodes as stale.cx.background_spawn runs tree-sitter's incremental parser using the grammar. Only the stale subtrees are re-parsed.Buffer::syntax_map. cx.notify() triggers a re-render which picks up the updated token highlights.