Skip to content

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

Zed 12 min read Deep dive mediumAdept

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

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.

Related posts

  • 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.

  • Text Coordinate Systems

    Zed mediumAdept

    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.

  • 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.

  • Xanadu Was Waiting for Agents

    Zed easyNovice

    Ted Nelson's Project Xanadu specified permanent versioning, span-level attribution and transclusion decades before its dependencies existed. Zed argues those pieces now exist: Lamport timestamps, Merkle-tree naming via Git, CRDTs, cheap storage, microVMs, Tree-sitter and GPUI. AI agents are the reader who will actually follow every link and version. DeltaDB stores files as fragments with stable identities, so anchors to code spans survive edits and stay linked to the conversations and operations that produced them. To avoid Xanadu's refusal to interoperate, every Delta thread is also a Git branch and can mirror to GitHub.

  • pg_crdt - an experimental CRDT extension for Postgres

    Supabase easyNovice

    pg_crdt is an experimental, open-source Postgres extension that adds CRDT column types (wrapping the Yjs and Automerge Rust libraries via pgx), so a column like a post's content can be a Yjs Doc whose updates are commutative and idempotent. Supabase argues for storing CRDTs in the database rather than making Realtime the authoritative server, to avoid coupling and enable tools like Debezium, while allowing per-column choice between last-write-wins and CRDT merging. Known limitations block production use: WAL-based broadcast sends the whole document on small edits, frequent updates generate heavy WAL and dead tuples, and large documents incur serialization overhead.

The quest for software engineering knowledge.

Look:
Layout: