#[non_exhaustive]pub enum FoldOp {
Add {
start_row: usize,
end_row: usize,
closed: bool,
},
RemoveAt(usize),
OpenAt(usize),
CloseAt(usize),
ToggleAt(usize),
OpenAll,
CloseAll,
ClearAll,
Invalidate {
start_row: usize,
end_row: usize,
},
}Expand description
Canonical fold-mutation op carried through FoldProvider::apply.
Introduced in 0.0.38 (Patch C-δ.4). The engine raises one FoldOp
per z… keystroke / :fold* Ex command and dispatches it through
the FoldProvider::apply surface. Hosts that own the fold storage
(default in-tree wraps &mut hjkl_buffer::Buffer) decide how to
apply it — possibly batching, deduping, or vetoing. Hosts without
folds use NoopFoldProvider which silently discards every op.
FoldOp is engine-canonical (per the design doc’s resolved
question 8.2): hosts don’t invent their own fold-op enums. Each
host that exposes folds embeds a FoldOp variant in its Intent
enum (or simply observes the engine’s pending-fold-op queue via
crate::Editor::take_fold_ops).
Row indices are zero-based and match the row coordinate space used
by hjkl_buffer::Buffer’s fold methods.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Add
:fold {start,end} / zf{motion} / visual-mode zf — register a
new fold spanning [start_row, end_row] (inclusive). The closed
flag matches the underlying hjkl_buffer::Fold::closed.
RemoveAt(usize)
zd — drop the fold under row if any.
OpenAt(usize)
zo — open the fold under row if any.
CloseAt(usize)
zc — close the fold under row if any.
ToggleAt(usize)
za — flip the fold under row between open / closed.
OpenAll
zR — open every fold in the buffer.
CloseAll
zM — close every fold in the buffer.
ClearAll
zE — eliminate every fold.
Invalidate
Edit-driven fold invalidation. Drops every fold touching the
row range [start_row, end_row]. Mirrors vim’s “edits inside a
fold open it” behaviour. Fired by the engine’s edit pipeline,
not bound to a z… keystroke.