M1.1: text buffer with UTF-16 positions, edit batches and line endings
lutra-text gets Buffer on a ropey rope: byte/char/UTF-16/line counts, byte offset <-> (line, column) in UTF-16 code units or chars, absolute UTF-16 offsets, atomic Edit batches in LSP TextEdit[] semantics, and \n / \r\n / \r detection with a keep-the-file's-ending save policy. All conversions return TextError instead of panicking. ropey 1.6.1 (MIT) without unicode_lines, so only the LSP/CodeMirror line breaks split lines. proptest moves into workspace deps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
faadb05eb3
commit
5dac918b14
12 changed files with 1278 additions and 3 deletions
|
|
@ -3,3 +3,22 @@
|
|||
//! Holds the rope buffer, line and column positions, UTF-8/UTF-16 offset
|
||||
//! conversion and edit application. Every other crate converts text offsets
|
||||
//! through this crate instead of slicing strings by hand.
|
||||
//!
|
||||
//! - [`Buffer`]: a [`ropey`] rope plus the file's [`LineEnding`].
|
||||
//! - [`Position`] and [`ColumnUnit`]: zero-based line and column, the
|
||||
//! column in UTF-16 code units (LSP, CodeMirror) or in chars.
|
||||
//! - [`Edit`] and [`Buffer::apply`]: atomic batches of byte-range edits.
|
||||
//! - [`TextError`]: every conversion and edit is fallible instead of
|
||||
//! panicking on bad offsets.
|
||||
|
||||
mod buffer;
|
||||
mod edit;
|
||||
mod error;
|
||||
pub mod line_ending;
|
||||
mod position;
|
||||
|
||||
pub use buffer::Buffer;
|
||||
pub use edit::Edit;
|
||||
pub use error::TextError;
|
||||
pub use line_ending::LineEnding;
|
||||
pub use position::{ColumnUnit, Position};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue