Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Zed 11 min read Deep dive mediumAdept

Text Coordinate Systems

Zed represents text positions with several coordinate types, each suited to a different job. `Point` (row/column) makes vertical movement easy but follows "typewriter" addition semantics, and `Offset` counts bytes from the start of the document, which suits multi-line ranges. `OffsetUtf16` and `PointUtf16` exist for the Language Server Protocol and are indexed directly in the Rope's SumTree, so conversions are fast. `DisplayPoint` maps positions onto the rendered view, accounting for soft wraps, folds, inlay hints, tabs and blocks. `Anchor` is a logical position tied to a Lamport-timestamped immutable insertion in Zed's CRDT, so it stays valid across concurrent edits and background work such as language-server requests.

Assumes: Rust basicstext encodings (UTF-8/UTF-16)CRDT basics

Related posts

  • How CRDTs make multiplayer text editing part of Zed's DNA

    Zed mediumAdept

    Zed builds collaborative editing into its core using CRDTs rather than Operational Transformation, making concurrent edits commutative by addressing text through stable logical anchors (insertion id plus offset) instead of absolute offsets. Each insertion gets a unique id from a centrally assigned replica id and a sequence number. Deletions are tombstones tagged with version vectors so concurrent insertions inside a deleted range stay visible, and concurrent inserts at the same spot are ordered by descending Lamport timestamp with replica id as tiebreaker to respect causality. Per-user undo/redo is also covered, and a copy-on-write B-tree avoids linear scans when resolving anchors.

  • Zed Weekly: #21

    Zed easyNovice

    Weekly team update from the Zed editor team. It covers initial Prettier integration and better LSP server log display, a storybook CLI for rendering new GPUI UI components in isolation, and Vim mode's command palette shipping to preview. Julia explains why vertical cursor movement drifts with mixed scripts, multi-codepoint graphemes like ZWJ emoji, and proportional fonts, and proposes tracking an intended pixel x-position resolved like a mouse click, which costs more compute. Other items include ClickHouse dashboard query optimization (minutes to under 10 seconds), the Semantic Index shipping to stable, cross-project following for channel notes, and CRDT Lamport-timestamp-based change notifications.

  • This Week at Zed Industries: #14

    Zed easyNovice

    Zed's weekly update covers a reworked search UI with semantic search, the start of WebAssembly extensions for custom language servers, and near-complete collaboration channels. The most technical section describes CRDB repository sync without vector timestamps. Client and server find a shared prefix of a Lamport-ordered operation log by comparing Bromberg associative-hash digests over ranges, computed in O(log n) via a B-tree, trading extra round trips against sending redundant operations. Channels are modeled as a DAG whose permissions cascade downward, and GPUI layout is expressed with chained Rust builder calls instead of a macro DSL.

  • This Week at Zed Industries: #12

    Zed mediumAdept

    Zed publicly launched its preview channel and reports progress across the editor: Vim search commands, macOS ctrl-click remapped to right click in the platform layer, terminal Cmd+hover navigation, a semantic index that collapses nested tree-sitter symbols to cut embedding tokens, and a lock-contention bug where slow git status in huge repos serializes file scanning. The most substantive section covers CRDB, Zed's planned collaboration backbone. It uses serde-bare instead of Protocol Buffers so message types live entirely in Rust, routes messages by TypeId, and syncs replicas with vector clocks as a distributed set union. Operations are applied by reconstructing revisions from a DAG of operations with cached snapshots and copy-on-write B-trees.

  • Rope & SumTree

    Zed mediumAdept

    Zed represents buffer text with a rope rather than a string, because contiguous strings make mid-file inserts and deletes, line navigation and very large files expensive. Its rope is not a classic binary-tree rope but a SumTree of fixed-capacity inline Chunks of at most 128 characters in release builds. The leaves are reference-counted via Arc, so edits mostly rewire pointers and snapshots are cheap. Concurrent access was the deciding requirement: every edit can hand a snapshot to a background thread for Tree-sitter re-parsing without copying the text, which made the rope win over gap buffers and piece tables.

The quest for software engineering knowledge.

Look:
Layout: