Skip to main content

EditingState

Struct EditingState 

Source
pub struct EditingState {
Show 14 fields pub mode_stack: ModeStack, pub pending_keys: KeySequence, pub windows: WindowLayout, pub viewport: Viewport, pub selection: Option<ClientSelection>, pub extensions: ExtensionMap, pub compositor: Option<Box<dyn RootCompositor>>, pub tabs: TabPageSet, pub registers: RegisterBank, pub clipboard_history: HistoryRing, pub local_marks: MarkBank, pub jumplist: Jumplist, pub active_buffer: Option<BufferId>, pub terminal_size: (u16, u16),
}
Expand description

Editing state for a client.

Contains all per-client state needed for editing operations. All clients have this state - it’s not just for “owners” anymore.

§Multi-Client Isolation (#471)

Each client owns their own WindowLayout with independent cursors. This ensures Client A’s cursor/mode doesn’t affect Client B. Buffers are still shared (all clients see same text content).

§Client Model Mapping (#480)

This struct maps to ClientViewState in the common client model. Only a subset is transmitted:

EditingState fieldClientViewState fieldTransform
mode_stackmode.current().name()
windowscursor: Position.focused().cursor
windowsbuffer_id.focused().buffer_id
selectionselection.to_driver_selection()

Per-client editing state (#471, #477).

Contains all client-specific state including mode, windows, viewport, selection, and module extensions. Each client has independent state to prevent cross-client interference (e.g., Client A’s pending count affecting Client B’s motions).

Fields§

§mode_stack: ModeStack

Mode stack (current mode on top).

§pending_keys: KeySequence

Keys accumulated but not yet processed.

§windows: WindowLayout

Per-client window layout with independent cursors (#471).

Each window contains its own cursor position. This replaces the old shared session.windows that caused multi-client bugs.

§viewport: Viewport

Viewport (visible area).

§selection: Option<ClientSelection>

Active selection (for visual mode).

§extensions: ExtensionMap

Per-client module extensions (#477).

Type-erased storage for module state like VimSessionState, SearchState, CmdlineState. Each client has independent extensions to prevent state leakage between clients.

§Why Per-Client

Without isolation, Client A pressing 5 (pending_count=5) would cause Client B’s j to move 5 lines instead of 1. This field ensures complete module state isolation.

§compositor: Option<Box<dyn RootCompositor>>

Per-client compositor for window layout (#474).

Each client owns their own compositor, cloned from the shared template at join time. This ensures window IDs are consistent between the compositor (geometry) and per-client windows (cursor/viewport).

Before this field, the shared compositor and per-client windows used independent ID namespaces, causing cross-namespace mismatches in notifications and state queries.

§tabs: TabPageSet

Per-client tab pages (#401).

Manages tab page lifecycle. Each tab can have its own window layout and compositor. Currently starts with a single default tab. Future work will integrate with windows and compositor fields so that active_tab().windows() becomes the source of truth.

§registers: RegisterBank

Per-client register storage (#515).

Each client owns their own registers (unnamed "", named a-z/A-Z). System clipboard (+, *) remains shared via ClipboardProvider. This prevents Client A’s "ayy from overwriting Client B’s register ‘a’.

§clipboard_history: HistoryRing

Per-client clipboard history ring (#515).

Tracks yank/delete history for numbered registers 0-9. Each client has independent history so Client A’s deletes don’t shift Client B’s numbered registers.

§local_marks: MarkBank

Per-client local marks (a-z, per-client special marks) (#515).

Each client owns their own local marks. Global marks (A-Z) remain shared in KernelContext.global_marks.

§jumplist: Jumplist

Per-client jump list for Ctrl-O / Ctrl-I navigation (#654).

Each client owns their own jump list. Jump positions are recorded on cursor movements across buffer boundaries or large jumps.

§active_buffer: Option<BufferId>

Per-client active buffer (#471).

Each client tracks which buffer they are viewing independently. New clients are initialized with the first kernel buffer (scratch).

§terminal_size: (u16, u16)

Per-client terminal dimensions (width, height) (#471).

Each client has independent terminal size. Initialized to VT100 default (80, 24); updated when the client sends a resize RPC.

Implementations§

Source§

impl EditingState

Source

pub fn with_mode_stack(mode_stack: ModeStack) -> Self

Create editing state with a specific mode stack.

Source

pub fn with_mode_stack_and_window(mode_stack: ModeStack, window: Window) -> Self

Create editing state with mode stack and initial window.

Used when a client joins a session that already has buffers.

Source

pub fn current_mode(&self) -> &ModeId

Get the current mode ID.

Source

pub fn clear_pending_keys(&mut self)

Clear pending keys.

Source

pub fn client_context(&mut self) -> ClientContext<'_>

Borrow the 7 per-client mutable fields as a [ClientContext].

This bundles the fields that SessionRuntime needs, avoiding 7-argument parameter lists throughout the session execution chain.

Trait Implementations§

Source§

impl Clone for EditingState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EditingState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EditingState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more