Skip to main content

diff_edit

Function diff_edit 

Source
pub fn diff_edit(old: &str, new: &str) -> Edit
Expand description

Recover a single contiguous Edit from a pair of whole texts by stripping the common prefix and suffix.

This is the fallback, not the hot path. The language server knows the exact range it spliced and must hand it over; re-deriving it here costs more than the reparse it feeds (fatou measured ~200 us of a ~500 us keystroke at 1 MB). It stays for texts that changed by a route carrying no edits — a disk reload, a whole-buffer replacement, a chain that failed to verify.

Multiple disjoint edits collapse into one spanning edit. Still a correct transform, just coarser — and a coarse one spans everything between the changes, which is exactly the shape a cost guard declines.