pub struct ActiveModes { /* private fields */ }Expand description
The set of modes active on a buffer. Exactly one major (or none, prior to first major activation), plus any number of minors in activation order.
Ordering invariant: minors are stored in the order they were activated; when an active mode is deactivated, the survivors retain their relative positions (no reshuffling). This is what M.2’s option-resolution layer relies on for “later activation wins” tie-breaking.
SmallVec keeps the typical case (0-4 minors) inline. A
buffer with more active minors spills to the heap; that’s
fine – the hot path is option resolution against the cached
ResolvedOptions, not iteration of ActiveModes.
Implementations§
Source§impl ActiveModes
impl ActiveModes
Sourcepub fn major(&self) -> Option<ModeId>
pub fn major(&self) -> Option<ModeId>
The active major, if any. None until the first major
activation runs (e.g. a freshly-opened scratch buffer
before mode resolution).
Sourcepub fn keymap_gated_ids(&self) -> Vec<ModeId>
pub fn keymap_gated_ids(&self) -> Vec<ModeId>
The mode ids the keymap lookup must gate on, in priority
order: the active major first (lowest of the gated layers),
then the minors in activation order (each overlaying the
previous). Pass this to
KeymapHandle::lookup_with_context so a MajorMode layer
fires only in buffers where that major is active — a bare
minors() slice would leave major-mode chords ungated
(they’d fire everywhere).
Sourcepub fn is_active_major(&self, mode: ModeId) -> bool
pub fn is_active_major(&self, mode: ModeId) -> bool
True iff mode is the active major.
Trait Implementations§
Source§impl Clone for ActiveModes
impl Clone for ActiveModes
Source§fn clone(&self) -> ActiveModes
fn clone(&self) -> ActiveModes
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more