Skip to main content

EditorTestApi

Trait EditorTestApi 

Source
pub trait EditorTestApi {
Show 18 methods // Required methods fn dispatch(&mut self, action: Action); fn dispatch_seq(&mut self, actions: &[Action]); fn buffer_text(&self) -> String; fn primary_caret(&self) -> Caret; fn carets(&self) -> Vec<Caret>; fn selection_text(&mut self) -> String; fn viewport_top_byte(&self) -> usize; fn terminal_width(&self) -> u16; fn terminal_height(&self) -> u16; fn gutter_width(&self) -> u16; fn hardware_cursor_position(&mut self) -> Option<(u16, u16)>; fn visible_byte_range(&self) -> Option<(usize, usize)>; fn modal_snapshot(&self) -> ModalSnapshot; fn buffer_count(&self) -> usize; fn active_buffer_path(&self) -> Option<String>; fn buffer_paths(&self) -> Vec<String>; fn dispatch_mouse_click(&mut self, col: u16, row: u16) -> bool; fn is_modified(&self) -> bool;
}
Expand description

The single observation surface for semantic theorem tests.

Implemented by crate::app::Editor. Tests obtain a &mut dyn EditorTestApi from the test harness and never see the underlying Editor type directly.

Required Methods§

Source

fn dispatch(&mut self, action: Action)

Apply a single semantic action, then drain async messages.

Source

fn dispatch_seq(&mut self, actions: &[Action])

Apply a sequence of actions in order, draining async messages once at the end. Equivalent to calling dispatch per action but cheaper.

Source

fn buffer_text(&self) -> String

Full buffer text. Panics if the buffer has unloaded regions (large-file mode); semantic theorems are not the right tool for large-file scenarios — write a layout/E2E test instead.

Source

fn primary_caret(&self) -> Caret

Primary cursor projected to a Caret.

Source

fn carets(&self) -> Vec<Caret>

All cursors projected to Carets, sorted by ascending position. The primary cursor is included. Use primary_caret() if you only care about the primary; use carets() for multi-cursor theorems.

Source

fn selection_text(&mut self) -> String

Concatenated selected text across all cursors, in ascending position order, joined by \n. Returns the empty string if no cursor has a selection.

Source

fn viewport_top_byte(&self) -> usize

Byte offset of the first line currently visible in the active viewport. After the renderer has run, this is the viewport’s scroll position. Without a render, this reflects the last reconciliation point.

Source

fn terminal_width(&self) -> u16

Width of the active terminal in cells, as set at harness construction or via resize.

Source

fn terminal_height(&self) -> u16

Height of the active terminal in cells.

Source

fn gutter_width(&self) -> u16

Width of the line-number gutter in cells, computed from the active buffer’s line count. Includes the trailing separator if the renderer adds one.

Source

fn hardware_cursor_position(&mut self) -> Option<(u16, u16)>

Screen cell of the primary cursor, in (col, row). None ⇒ the cursor is off-screen (scrolled past). Requires a prior render to be meaningful.

Source

fn visible_byte_range(&self) -> Option<(usize, usize)>

(start_byte, end_byte) of the currently-visible buffer region. End is exclusive. None ⇒ unknown / not yet reconciled.

Source

fn modal_snapshot(&self) -> ModalSnapshot

Snapshot of the modal-popup stack visible to the user. Used by ModalScenario to assert on palette / picker / menu / completion state without screen scraping.

Source

fn buffer_count(&self) -> usize

Number of buffers currently open across the workspace.

Source

fn active_buffer_path(&self) -> Option<String>

Display path of the active buffer. None for unnamed buffers.

Source

fn buffer_paths(&self) -> Vec<String>

Display paths of every open buffer in stable insertion order. Unnamed buffers appear as "<unnamed:NNN>".

Source

fn dispatch_mouse_click(&mut self, col: u16, row: u16) -> bool

Dispatch a mouse click projected through the active viewport. (col, row) are absolute screen coordinates; gutter offset is applied internally. Returns true if the editor consumed the event.

Source

fn is_modified(&self) -> bool

true if the active buffer has unsaved changes since it was last loaded from / saved to disk. The “save point” is the commit in the undo/redo log at which the buffer’s on-disk representation matches its in-memory state. After loading a fresh file (no edits applied), this is false. After any edit it becomes true. Undoing back to the save point flips it back to false — the property under test in tests/semantic/undo_redo.rs::theorem_undo_to_save_point_*.

Implementors§