Skip to main content

Module apply

Module apply 

Source
Expand description

Turning a formatter’s whole-file output into a minimal edit set.

A formatter returns a new file, not a patch. Splicing that over the buffer would be the obvious implementation and the wrong one: it destroys cursor position, marks and folds, invalidates every renderer fast path, and shows as a full-viewport repaint — a UX veto even when the visible text is unchanged.

lattice-diff already computes line-granular hunks for the diff subsystem, and line granularity is the right resolution here: a formatter’s unit of change is the line.

Functions§

changes_more_than_indentation
Whether new differs from old in more than leading whitespace.
minimal_edits
Edits that transform old into new, one per changed region.