pub struct SnippetSession { /* private fields */ }Expand description
The live snippet sessions, keyed by the buffer each is expanding in (a buffer is absent from the map when no snippet is live there).
Implementations§
Source§impl SnippetSession
impl SnippetSession
pub fn new() -> Self
Sourcepub fn is_active(&self, buffer: BufferId) -> bool
pub fn is_active(&self, buffer: BufferId) -> bool
true while a snippet is expanding in buffer. Backs the
host’s many readers (keymap overlay sync, render state, …),
each of which names the buffer it cares about so a session in
one buffer never activates the mode in another.
Sourcepub fn set(&self, buffer: BufferId, active: ActiveSnippet)
pub fn set(&self, buffer: BufferId, active: ActiveSnippet)
Install a freshly-expanded session in buffer, replacing any
prior session for that same buffer.
Sourcepub fn clear(&self, buffer: BufferId)
pub fn clear(&self, buffer: BufferId)
End the session in buffer (reached $0, or the buffer/mode
tore down). A no-op if buffer had no live session.
Sourcepub fn with_mut<R>(
&self,
buffer: BufferId,
f: impl FnOnce(&mut Option<ActiveSnippet>) -> R,
) -> R
pub fn with_mut<R>( &self, buffer: BufferId, f: impl FnOnce(&mut Option<ActiveSnippet>) -> R, ) -> R
Mutate the live session for buffer in place. The closure sees
an Option so it can advance the focused tabstop and end the
session (set it to None) in one critical section — setting it
to None removes the buffer’s entry from the map.