pub struct OilSnapshot { /* private fields */ }Expand description
The directory state an oil buffer diffs against: the entries as
they were at open, or at the last successful :w.
DL.5: this used to be OilBuffer, carrying the rope, a cursor and
a scroll alongside the snapshot. The rope moved into an
actor-backed Document (the buffer is one now), and the cursor /
scroll were archival duplicates of the pane’s that the hot path
never read — their own doc comment said reading them was unsafe.
What is left is the only thing oil genuinely owns: what the
directory looked like, so :w can tell what the user changed.
The current text is passed in rather than held, because the Document owns it. That is also what keeps the rope bare filenames: icons are virtual text, so the diff sees exactly what the user typed.
Does NOT hold the directory path — that lives in the OilDir
BufferLocal.
Implementations§
Source§impl OilSnapshot
impl OilSnapshot
Sourcepub fn is_dirty(&self, current_text: &str) -> bool
pub fn is_dirty(&self, current_text: &str) -> bool
True when current_text differs from what the snapshot renders
to — i.e. the user edited the listing.
Sourcepub fn snapshot_names(&self) -> Vec<&str>
pub fn snapshot_names(&self) -> Vec<&str>
Names from the snapshot (used by apply and tests).
Sourcepub fn snapshot_entries(&self) -> &[OilEntry]
pub fn snapshot_entries(&self) -> &[OilEntry]
Snapshot entries (used by renderer).
Sourcepub fn entry_at_line(&self, line: u32) -> Option<&OilEntry>
pub fn entry_at_line(&self, line: u32) -> Option<&OilEntry>
Entry at line in the snapshot.
Sourcepub fn apply(&mut self, dir: &Path, current_text: &str) -> Result<()>
pub fn apply(&mut self, dir: &Path, current_text: &str) -> Result<()>
Diff rope against snapshot and execute filesystem operations
relative to dir. Order: renames → deletes → creates.
On error: stops, returns the error (caller echoes it).
On success: refreshes snapshot to new disk state.
dir is supplied by the caller from
buffer_locals[id].get::<OilDir>(). Passing it explicitly
instead of storing on the buffer eliminates the class of
sync bug where post-navigate state could drift (the
buffer-local IS the state).
Trait Implementations§
Source§impl Clone for OilSnapshot
impl Clone for OilSnapshot
Source§fn clone(&self) -> OilSnapshot
fn clone(&self) -> OilSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more