Skip to main content

EditorActorHandle

Struct EditorActorHandle 

Source
pub struct EditorActorHandle { /* private fields */ }
Expand description

Renderer-side handle to the editor actor.

Holds:

  • cmd_tx — unbounded; the renderer sends commands without blocking. Backpressure is the actor’s per-command processing cost; today every command processes in microseconds so the queue stays effectively empty.
  • signal_rx — unbounded; the renderer drains signals once per frame via Self::poll_signal. The actor pushes signals as it processes commands.
  • render_state — a clone of the editor’s Arc<ArcSwap<RenderState>>. The renderer loads via handle.render_state.load() (wait-free); the editor’s publish_render_state calls are observable through this shared Arc.

Not Clone: the signal_rx is uniquely owned. Renderers that need to send commands from multiple places can clone the underlying mpsc::UnboundedSender via Self::cmd_sender, which is freely Clone.

Implementations§

Source§

impl EditorActorHandle

Source

pub fn send(&self, cmd: EditorCommand) -> Result<(), SendError<EditorCommand>>

Send a command to the editor actor. Returns Err only when the actor has already shut down (channel closed). In production this should never happen during normal operation; in tests the failure mode is “test forgot to keep the handle alive.”

Source

pub fn send_action( &self, action: Action, ) -> Result<(), SendError<EditorCommand>>

Convenience: send an Apply(action) command. Fire-and- forget — does not wait for completion. The renderer keystroke handler uses this so the input loop returns immediately; the dispatched action runs on the actor thread and publishes RenderState when done (the existing paint_request Notify wakes the GPUI peer’s next paint).

Source

pub fn apply_blocking(&self, action: Action) -> Result<(), ActorGone>

Synchronous dispatch — blocks until the actor finishes processing this action (and any cascade). Used by App::apply so existing call sites that read editor- derived state on the next line keep working. Returns Err only if the actor died mid-await.

Safe to call from inside or outside a tokio runtime: safe_blocking_recv selects the right wait path based on the current runtime flavor (see its docstring).

Source

pub fn mutate_blocking( &self, closure: Box<dyn FnOnce(&mut Editor) + Send>, ) -> Result<(), ActorGone>

Closure escape hatch — synchronous: send the closure + block until the actor runs it and publishes RS. Used by App-side helpers during the slice-E sweep when the helper’s body mutates editor state directly. Each helper wraps its body in one closure; the caller’s read-back of editor-derived state via app.ad() etc. sees the post- mutation snapshot.

Source

pub fn mutate_async( &self, closure: Box<dyn FnOnce(&mut Editor) + Send>, ) -> Result<(), ActorGone>

Closure escape hatch — fire-and-forget. For tokio task callers that can’t block (e.g., LSP response handlers).

Source

pub fn with_editor<R, F>(&self, f: F) -> R
where R: Send + 'static, F: FnOnce(&Editor) -> R + Send + 'static,

Read-side RPC (3c.final.E.swap): synchronously run a closure against &Editor on the actor thread and return the result. Used by every &self-receiver helper on App / GpuiApp that needs to read editor state. Internally uses Box<dyn Any> erasure to keep the actor’s command enum non-generic.

Source

pub fn mutate_blocking_with<R, F>(&self, f: F) -> R
where R: Send + 'static, F: FnOnce(&mut Editor) -> R + Send + 'static,

Sync mutate RPC with return value (3c.final.E.swap). Used by mutate_editor_with post-swap: the closure returns R; the actor publishes RS at its tail.

Source

pub fn set_cursor( &self, cursor: Position, ) -> Result<(), SendError<EditorCommand>>

Replace the editor’s cursor and republish.

Source

pub fn set_cursor_line(&self, line: u32) -> Result<(), SendError<EditorCommand>>

Replace cursor.line and republish.

Source

pub fn set_cursor_byte(&self, byte: u32) -> Result<(), SendError<EditorCommand>>

Replace cursor.byte and republish.

Source

pub fn set_scroll(&self, scroll: u32) -> Result<(), SendError<EditorCommand>>

Replace scroll and republish.

Source

pub fn set_modal( &self, modal: ModalState, ) -> Result<(), SendError<EditorCommand>>

Replace modal and republish.

Source

pub fn set_viewport_height( &self, height: u32, ) -> Result<(), SendError<EditorCommand>>

Resize the active pane’s viewport. Runs the same body as the App-side wrapper: clamp to >= 1, run ensure_cursor_visible, publish.

Source

pub fn set_pane_viewport( &self, idx: usize, height: u32, width: u32, ) -> Result<(), SendError<EditorCommand>>

Issue #25 (2026-05-22): per-pane geometry setter. The renderer’s per-frame layout pass walks the pane tree and fires one of these per leaf. The active leaf’s height is auto-mirrored into Editor::viewport_height for cursor clamp + highlights worker.

Source

pub fn poll_signal(&mut self) -> Option<RendererSignal>

Drain a single pending signal from the editor’s signal stream. Returns None when the queue is empty (steady-state on most frames). Called per-frame by the renderer; the typical drain pattern is while let Some(sig) = handle.poll_signal() { ... }.

Source

pub fn cmd_sender(&self) -> UnboundedSender<EditorCommand>

Cheap clone of the command-send side. Use this when multiple call sites in the renderer need to send commands without sharing a &self to the full handle.

Source

pub fn render_state(&self) -> Arc<RenderState> ⓘ

Wait-free read of the current RenderState snapshot. Returns an Arc<RenderState> the renderer holds across the frame.

Source

pub fn render_state_arc(&self) -> Arc<ArcSwap<RenderState>> ⓘ

Shared ArcSwap reference for callers that need to store it alongside other Arc-shared state (e.g., a renderer that wants to clone the cell into a paint closure).

Source

pub fn paint_request(&self) -> Arc<Notify> ⓘ

Shared paint_request Notify the actor’s workers fire after an async republish (syntax recolour, LSP decoration, cells/virtual-rows). The TUI event loop (I.3) awaits this to repaint promptly; the GPUI peer uses the same notify natively.

Source

pub fn shutdown_and_join(&mut self) -> Result<()>

Send Shutdown and join the editor thread. Idempotent in the sense that subsequent calls return Ok(()) without re-joining. Returns Err only if the thread panicked.

Trait Implementations§

Source§

impl Drop for EditorActorHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> IntoMaybeUndefined<T> for T

§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
§

impl<T> IntoOption<T> for T

§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Pointer = u32

§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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