pub fn apply_buffer_edit(buf: &mut View, edit: Edit) -> EditExpand description
Apply a hjkl_buffer::Edit and return the inverse for undo.
0.0.42 (Patch C-δ.7): the apply_edit reach is intentionally kept
against the concrete &mut hjkl_buffer::View rather than lifted
onto a trait method. Rationale:
hjkl_buffer::Editis the rich buffer-side enum (~8 variants —InsertChar,InsertStr,DeleteRange,JoinLines,SplitLines,Replace,InsertBlock,DeleteBlockChunks) with ~700 LOC ofdo_*machinery inhjkl-buffer. Lifting it ontoBufferEditwould require either an associatedEdittype (forces every backend to design its own rich-edit enum just to compile) or duplicating the 8 variants on the trait surface (busts the discipline cap).crate::types::Editis a separate value type (Range<Pos>+Stringreplacement) used by the change-log emitter; it’s intentionally simpler and lossy for block / join / split ops.
Centralizing the reach in this free fn keeps Editor::mutate_edit
trait-shaped at the call site (no self.buffer.<inherent> hop in
the editor body) and gives 0.1.0 a single seam to flip when the
B: View generic lands.
The 0.1.0 design will introduce
BufferEdit::apply_edit(&mut self, op: Self::Edit) -> Self::Edit
with type Edit; so backends pick their own edit enum. This free
fn forwards there once that lands.