Company
Date Published
Author
Thorsten Ball, Nathan Sobo, and Antonio Scandurra
Word count
2785
Language
English
Hacker News points
None

Summary

The text explores the complexities of text coordinate systems within the Zed text editor, highlighting the use of multiple systems beyond the standard lines and columns, including Points, Offsets, UTF-16 Offsets, DisplayPoints, and Anchors. Points are a basic system involving rows and columns, but navigating them can be tricky due to varying line lengths. Offsets provide a byte count from the start of a document, while UTF-16 variants are used for communication with language servers. DisplayPoints refer to the visual representation of text, taking into account features like soft-wrapping and inlay hints, which differ from the actual file structure. Anchors differ as they provide a logical coordinate system that maintains references to text positions despite edits, essential for collaborative editing and background processing. Anchors, tied closely to Zed's collaborative features and CRDTs, use Lamport timestamps to maintain stable references, allowing for continuous text manipulation and background processing without losing position integrity.