Here is the complete chain from a keypress to a text change, using 'a' typed at cursor position 10 as an example:
Insert { text: "a" }Keymap looks up the keystroke in the active bindings. Most printable characters resolve to a generic Insert action. (See GPUI.)Editor::handle_input()self.insert(text, cx).Editor::insert() — computes edits from selectionsMultiBuffer::edit() — transactional editMultiBuffer maps the display-space edit to excerpt coordinates and forwards to each underlying Buffer.Buffer::edit() — CRDT op appliedTextBuffer records the insertion. Observers (syntax re-parser, LSP notifier) receive a BufferEvent::Edited. See Buffer & Language.cx.notify() calledcx.notify() queues a re-render, which flows through the display pipeline. See Rendering.Defined in actions.rs. Actions are defined with the actions! macro for zero-data actions or #[derive(Action)] for actions with data.
DisplayMap (display_map.rs) sits between the raw buffer and the rendered output. It answers questions like "where on screen does buffer position 42 appear?"
| Transform | What it does |
|---|---|
| Soft wrap | Splits long lines at the viewport edge — buffer line 1 might become display rows 1 and 2 |
| Folding | Collapses a range (e.g. a function body) to a single placeholder row |
| Inlay hints | Inserts virtual text from LSP between buffer characters (type annotations, parameter names) |
| Git diff hunks | Inserts virtual lines for added/removed content from the current diff |
| Diagnostic messages | Appends inline error/warning text at end of line |
The rendering code always works in display-space coordinates. Conversions between buffer and display space go through DisplaySnapshot::buffer_point_to_display_point() and the inverse.