pub trait FoldProvider: Send {
// Required methods
fn next_visible_row(&self, row: usize, row_count: usize) -> Option<usize>;
fn prev_visible_row(&self, row: usize) -> Option<usize>;
fn is_row_hidden(&self, row: usize) -> bool;
fn fold_at_row(&self, row: usize) -> Option<(usize, usize, bool)>;
// Provided methods
fn apply(&mut self, op: FoldOp) { ... }
fn invalidate_range(&mut self, start_row: usize, end_row: usize) { ... }
}Expand description
Fold-iteration + mutation trait. The engine asks “what’s the next
visible row” / “is this row hidden” through this surface, and
dispatches fold mutations through FoldProvider::apply, so fold
storage can live wherever the host pleases (on the buffer, in a
separate host-side fold tree, or absent entirely).
Introduced in 0.0.32 (Patch C-β) for read access; 0.0.38 (Patch
C-δ.4) added FoldProvider::apply + FoldProvider::invalidate_range
so engine call sites that used to call
hjkl_buffer::Buffer::{open,close,toggle,…}_fold_at directly route
through this trait now. The canonical read-only implementation
crate::buffer_impl::BufferFoldProvider wraps a
&hjkl_buffer::Buffer; the canonical mutable implementation
crate::buffer_impl::BufferFoldProviderMut wraps a
&mut hjkl_buffer::Buffer. Hosts that don’t care about folds can
use NoopFoldProvider.
The engine carries a Box<dyn FoldProvider + 'a> slot today and
looks up rows through it. Once Editor<B, H> flips generic
(Patch C, 0.1.0) the slot moves onto Host directly.
Required Methods§
Sourcefn next_visible_row(&self, row: usize, row_count: usize) -> Option<usize>
fn next_visible_row(&self, row: usize, row_count: usize) -> Option<usize>
First visible row strictly after row, skipping hidden rows.
None past the end of the buffer.
Sourcefn prev_visible_row(&self, row: usize) -> Option<usize>
fn prev_visible_row(&self, row: usize) -> Option<usize>
First visible row strictly before row. None past the top.
Is row currently hidden by a closed fold?
Provided Methods§
Sourcefn apply(&mut self, op: FoldOp)
fn apply(&mut self, op: FoldOp)
Apply a FoldOp to the underlying fold storage. Read-only
providers (e.g. crate::buffer_impl::BufferFoldProvider which
holds a &Buffer) and providers that don’t track folds (e.g.
NoopFoldProvider) implement this as a no-op.
Default impl is a no-op so that read-only / host-stub providers
don’t need to override it; mutable providers
(e.g. crate::buffer_impl::BufferFoldProviderMut) override
this to dispatch to the underlying buffer’s fold methods.
Sourcefn invalidate_range(&mut self, start_row: usize, end_row: usize)
fn invalidate_range(&mut self, start_row: usize, end_row: usize)
Drop every fold whose range overlaps [start_row, end_row].
Edit pipelines call this after a user edit so vim’s “edits
inside a fold open it” behaviour fires. Default impl forwards
to FoldProvider::apply with a FoldOp::Invalidate.