Skip to main content

Module edit

Module edit 

Source
Expand description

Byte-range text edits.

Edit is the parser’s one edit currency: a byte range in some old text plus the string that replaces it. Everything here is pure text manipulation with no parser content; [super::reparse] re-exports it so parser::Edit is the single path the parser layer uses. Converting LSP didChange content changes into these lives host-side (crate::lsp in the root crate), which keeps this crate free of protocol dependencies and wasm-clean.

Edits reaching the reparse are untrusted. A language server can hand over a chain staged against a buffer that has since moved, and slicing on a stale range is a panic in an analysis query rather than a wrong answer. So every consumer validates before it slices: try_apply_edits is the apply-and-verify guard, and reconstructing the current buffer from an old snapshot plus a chain is what proves the chain is the exact transform between them.

Structs§

Edit
A single contiguous text edit: replace range (a byte range in the old text) with insert.

Functions§

apply_edits
Apply edits to old left-to-right, each expressed against the text its predecessors produced — the shape an LSP didChange batch arrives in.
diff_edit
Recover a single contiguous Edit from a pair of whole texts by stripping the common prefix and suffix.
try_apply_edits
apply_edits for an edit chain of unproven provenance: None when any edit does not fit the text its predecessors produced.