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<(), Error>
pub fn apply(&mut self, dir: &Path, current_text: &str) -> Result<(), Error>
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 moreSource§impl Debug for OilSnapshot
impl Debug for OilSnapshot
Source§impl Default for OilSnapshot
impl Default for OilSnapshot
Source§fn default() -> OilSnapshot
fn default() -> OilSnapshot
Auto Trait Implementations§
impl Freeze for OilSnapshot
impl RefUnwindSafe for OilSnapshot
impl Send for OilSnapshot
impl Sync for OilSnapshot
impl Unpin for OilSnapshot
impl UnsafeUnpin for OilSnapshot
impl UnwindSafe for OilSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more