Skip to main content

DisciplineState

Trait DisciplineState 

Source
pub trait DisciplineState: Any + Debug {
    // Required methods
    fn coarse_mode(&self) -> CoarseMode;
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;
    fn reset_to_idle(&mut self);
    fn reset_mode_after_history(&mut self);
}
Expand description

Discipline-private FSM state, stored type-erased on the Editor.

Required Methods§

Source

fn coarse_mode(&self) -> CoarseMode

Discipline-agnostic coarse mode for app chrome (status badge, cursor shape). Every discipline projects its internal mode onto this.

Source

fn as_any(&self) -> &dyn Any

Upcast to &dyn Any so the owning crate can downcast_ref to its concrete state type.

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Mutable upcast — see DisciplineState::as_any.

Source

fn reset_to_idle(&mut self)

Return the discipline to its idle / command-ready state, discarding any in-flight input (pending chords, counts, insert sessions).

The engine calls this when an operation must leave the editor in a known resting state regardless of which discipline is installed — after undo / redo, and after a :! filter rewrites the buffer. Without this hook the engine core would have to name vim to reset vim (#267).

For vim this is Normal mode; a non-modal discipline may treat it as a no-op.

Source

fn reset_mode_after_history(&mut self)

Put the discipline’s mode back to idle after undo / redo rewound the buffer, WITHOUT discarding in-flight session state.

Deliberately weaker than DisciplineState::reset_to_idle: undo must not clear an open insert session, because non-modal disciplines (vscode) live inside one permanently and rely on it for undo granularity. Getting this wrong silently breaks vscode-mode undo while leaving vim green.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§