Skip to main content

Editor

Struct Editor 

Source
pub struct Editor {
Show 69 fields pub docs: Arena<DocumentKind, Document>, pub io: IoState, pub tape: Rc<Tape>, pub git_view: WorkerId, pub git_discovery: Load<ContextKey>, pub hunk_load: Load<HunkKey>, pub hunks_untracked: bool, pub log_requests: HashMap<DocumentId, Ticket<LogKey>>, pub card_request: Option<Ticket<CardKey>>, pub dive_requests: HashMap<DocumentId, Ticket<DiveKey>>, pub git_mutations: VecDeque<GitMutation>, pub git_mutation: Option<Ticket<MutationKey>>, pub jumplist_past: Vec<(DocumentId, usize)>, pub jumplist_future: Vec<(DocumentId, usize)>, pub mode: Mode, pub pending: PendingInput, pub walker: Walker, pub undo_browser: Option<UndoBrowser>, pub last_find: Option<(char, bool, bool)>, pub last_search: Option<LastSearch>, pub registers: HashMap<char, Register>, pub marks: HashMap<char, (DocumentId, usize)>, pub flash: Option<(Range, Tick)>, pub message: String, pub should_quit: bool, pub ctrl_c_armed: bool, pub last_visual: Option<(usize, usize)>, pub last_insert_pos: Option<usize>, pub change_idx: Option<(usize, usize)>, pub view_rows: usize, pub recording: Option<char>, pub app_tx: Option<EventSender>, pub macros: HashMap<char, Vec<Key>>, pub last_macro: Option<char>, pub macro_depth: usize, pub picker: Option<PickerGlue>, pub resolution: ResolutionState, pub cwd: PathBuf, pub workspaces: WorkspaceRegistry, pub mru: Vec<DocumentId>, pub previews: Previews, pub git: Option<GitContext>, pub preview_tx: Sender<PreviewResult>, pub preview_rx: Option<Receiver<PreviewResult>>, pub hunks: HunkSet, pub staged_hunks: HunkSet, pub blame_card: Option<BlameCard>, pub blame_gutters: HashMap<DocumentId, BlameGutter>, pub generation: u64, pub git_tx: Sender<GitJob>, pub git_rx: Option<Receiver<GitJob>>, pub osc52: Option<String>, pub terminal_output: Vec<String>, pub needs_repaint: bool, pub clip_tx: Sender<ClipboardResult>, pub clip_rx: Option<Receiver<ClipboardResult>>, pub clip_paste_pending: Option<(bool, Ticket<ClipboardKey>)>, pub lsp_servers: Vec<LspServer>, pub diags: HashMap<DocumentId, DocumentDiagnostics>, pub hover_card: Option<String>, pub shell_tx: Sender<ShellResult>, pub shell_rx: Option<Receiver<ShellResult>>, pub panes: Vec<Pane>, pub active_pane: usize, pub layout: LayoutDir, pub config: Config, pub state_dir: Option<PathBuf>, pub session_policy: SessionPolicy, pub frame_draw: Option<FrameDraw>, /* private fields */
}

Fields§

§docs: Arena<DocumentKind, Document>§io: IoState§tape: Rc<Tape>§git_view: WorkerId§git_discovery: Load<ContextKey>§hunk_load: Load<HunkKey>§hunks_untracked: bool§log_requests: HashMap<DocumentId, Ticket<LogKey>>§card_request: Option<Ticket<CardKey>>§dive_requests: HashMap<DocumentId, Ticket<DiveKey>>§git_mutations: VecDeque<GitMutation>§git_mutation: Option<Ticket<MutationKey>>§jumplist_past: Vec<(DocumentId, usize)>

vim’s jumplist (ctrl-o/ctrl-i): past/future stacks of (document, byte offset) (jumps.rs).

§jumplist_future: Vec<(DocumentId, usize)>§mode: Mode§pending: PendingInput§walker: Walker

The input walker (0008 stage 2): typed parser state for counts/registers/operators/prefixes — pending stays for the free-text lines only.

§undo_browser: Option<UndoBrowser>

Space u browser state (editor/undo.rs); None when closed.

§last_find: Option<(char, bool, bool)>

Last f/F/t/T find: (char, backward, till). ; and , replay it.

§last_search: Option<LastSearch>

Armed by //?/*/# searches. n/N replay it; the render highlights matches persistently (rootle: current match underlined).

§registers: HashMap<char, Register>§marks: HashMap<char, (DocumentId, usize)>

Marks: char → (document, byte offset). m{a} sets, '{a} jumps.

§flash: Option<(Range, Tick)>§message: String§should_quit: bool§ctrl_c_armed: bool

ctrl-c is armed after the first warn (0015 quit policy).

§last_visual: Option<(usize, usize)>

Last visual range for gv (recorded per visual-mode key).

§last_insert_pos: Option<usize>

Where the last insert session was for gi.

§change_idx: Option<(usize, usize)>

g;/g, walk: (index, history depth it was taken at) — a new commit invalidates the walk.

§view_rows: usize

Text area height in rows — the render loop feeds it via scroll_to_cursor; viewport motions read it.

§recording: Option<char>

Macro recording (0016): the register being recorded into.

§app_tx: Option<EventSender>

The app event channel (0018): set by connect_events; late LSP attaches forward through it.

§macros: HashMap<char, Vec<Key>>

Recorded macros: register → key events.

§last_macro: Option<char>

The last replayed macro register (@@).

§macro_depth: usize

Macro self-replay depth guard.

§picker: Option<PickerGlue>§resolution: ResolutionState§cwd: PathBuf§workspaces: WorkspaceRegistry

Bound workspace contexts (0042 slice 2): one per filesystem in use.

§mru: Vec<DocumentId>

MRU document order (most recent first); drives Space b.

§previews: Previews

Picker preview file cache.

§git: Option<GitContext>

Git working surface state (M2).

§preview_tx: Sender<PreviewResult>

Preview file reads run on worker threads (0001 §3); results and the in-flight set are drained in drain_picker.

§preview_rx: Option<Receiver<PreviewResult>>§hunks: HunkSet§staged_hunks: HunkSet

HEAD↔index — the staged set (0014 wave 4); rendered in the gutter’s committed-adjacent color.

§blame_card: Option<BlameCard>

Git memory (M3): per-buffer surface kinds, blame card, job channel, OSC52 clipboard payload drained by the TUI.

§blame_gutters: HashMap<DocumentId, BlameGutter>

Each full/range/tail document owns its own revision-checked gutter.

§generation: u64

Bumped on every buffer-list mutation; git jobs carry the generation they were spawned under so results for dead surfaces are dropped (0011 §2).

§git_tx: Sender<GitJob>§git_rx: Option<Receiver<GitJob>>§osc52: Option<String>§terminal_output: Vec<String>§needs_repaint: bool

ctrl-l: the terminal desynced from the model — the draw loop answers with a full repaint (vim’s redraw).

§clip_tx: Sender<ClipboardResult>

System-clipboard reads (paste from +) run on a worker thread; clip_paste_pending remembers before/after AND the initiating document until the read lands (0023 §4).

§clip_rx: Option<Receiver<ClipboardResult>>§clip_paste_pending: Option<(bool, Ticket<ClipboardKey>)>§lsp_servers: Vec<LspServer>

LSP server pool (0014 wave 2): one client per (workspace root, server) — a rust file and a python file in one session get their own servers. Diagnostics by path, hover card, open bookkeeping.

§diags: HashMap<DocumentId, DocumentDiagnostics>§hover_card: Option<String>§shell_tx: Sender<ShellResult>

Shell jobs (:!cmd output buffers, |cmd pipes): results land in drain_shell — never a subprocess on the input path (0001 §3).

§shell_rx: Option<Receiver<ShellResult>>§panes: Vec<Pane>

Splits: flat row/column of panes (v1; tree layout later).

§active_pane: usize§layout: LayoutDir§config: Config

User config (0005-lite: TOML, embedded defaults, never bricks).

§state_dir: Option<PathBuf>

Shared state root for explicit trust and optional session persistence.

§session_policy: SessionPolicy§frame_draw: Option<FrameDraw>

Injected frame renderer (0046): cell-grid production belongs to the binary; replay of a recorded Frame action renders through this hook. The engine never renders on its own.

Implementations§

Source§

impl Editor

Source

pub fn blame_gutter_for(&self, buffer: DocumentId) -> Option<&BlameGutter>

The buffer’s blame gutter, if its data is still trustworthy: same revision, same line count. Any edit since the capture voids the line↔buffer-line pairing. A remote buffer pairs only with its endpoint-qualified entry.

Source§

impl Editor

Source

pub fn enter_block_pub(&mut self)

Source

pub fn block_rect_pub(&self) -> Option<BlockRect>

Source§

impl Editor

Source

pub fn recorded_action(&mut self, action: Action, tick: Tick) -> Result<()>

Live drivers: record the action, then run the shared body.

Source§

impl Editor

Source

pub fn trace_state(&mut self)

Source§

impl Editor

Source

pub fn document_analysis( &mut self, document: DocumentId, first: usize, last: usize, left: usize, width: usize, ) -> Option<Arc<FrameAnalysis>>

Source

pub fn preview_analysis( &mut self, path: &Path, first: usize, last: usize, width: usize, ) -> Option<Arc<FrameAnalysis>>

Source

pub fn search_summary( &self, query: &CompiledQuery, ) -> Option<&Result<SearchSummary, String>>

Source§

impl Editor

Source

pub fn head(&self) -> usize

The primary cursor’s byte offset (was the cursor field).

Source

pub fn set_head(&mut self, pos: impl Into<ByteOffset>)

Source

pub fn anchor(&self) -> usize

The visual anchor (== head when not in visual mode).

Source

pub fn extra_selections(&self) -> &[Selection]

Extra selections beyond the primary (0013).

Source

pub fn flash_range(&self) -> Option<Range>

Source

pub fn clamp_cursor(&mut self)

Source

pub fn scroll_to_cursor(&mut self, rows: usize)

Keep the cursor on screen; rows = text area height. The render loop calls this every frame, so it doubles as the viewport-height feed for the H/M/L/zz/ctrl-d family.

Source§

impl Editor

Source

pub fn diag_counts(&self, idx: DocumentId) -> (usize, usize)

(errors, warnings) on the buffer — the modeline’s diag chips.

Source

pub fn diag_message_at( &self, idx: DocumentId, line_1based: usize, ) -> Option<(Severity, &str)>

The worst diagnostic’s (severity, message) on a 1-based line — the cursor line’s end-of-line note (0009 UX).

Source

pub fn diag_ranges_at( &self, idx: DocumentId, line_1based: usize, ) -> Vec<(usize, usize, Severity)>

Diagnostic spans on a 1-based line as (col, end_col, severity) — the undercurl layer (0009 UX). Same-line diags only; columns are byte offsets into the line.

Source

pub fn diag_severity_at( &self, idx: DocumentId, line_1based: usize, ) -> Option<Severity>

Worst diagnostic severity for a 1-based line of buffer idx, if any (0001 pillar 4: merges with the git gutter). Per-buffer, so panes show their own diagnostics.

Source§

impl Editor

Source

pub fn touch_mru(&mut self, i: DocumentId)

Mark a document most-recently-used.

Source

pub fn cur(&self) -> &Document

The current document. Invariant: the editor always has one live document while it runs (closing the last one sets should_quit).

Source

pub fn buf(&self) -> &Buffer

Source

pub fn buf_mut(&mut self) -> BufferEdit<'_>

Source

pub fn doc(&self, id: DocumentId) -> &Document

One document by id — stale ids panic: an id outliving its document is a bug, and the generation check is what keeps it from silently resolving to the wrong one (0014 wave 2).

Source

pub fn current(&self) -> DocumentId

The active document (derived: the active view’s document).

Source

pub fn switch_to(&mut self, id: DocumentId)

Switch the active view to a document.

Source

pub fn sels(&self) -> &SelectionSet

The active view’s selections.

Source

pub fn sels_mut(&mut self) -> &mut SelectionSet

Source

pub fn view_rows(&self) -> usize

The active view’s scroll offset. The active pane’s text-area height in rows (render-loop fed).

Source

pub fn view_top(&self) -> usize

Source

pub fn close_buffer(&mut self, force: bool) -> bool

Close the current document; quits when the last one closes. Returns false when unsaved changes block the close. Generational ids mean no reindexing anywhere (0014 wave 2).

Source

pub fn any_dirty(&self) -> bool

Any path-backed or scratch document holding unsaved content.

Source

pub fn ctrl_c_quit(&mut self) -> bool

ctrl-c’s quit intent (0015): warn once when dirty work exists, force on the second press. Returns true when the app may exit.

Source§

impl Editor

Source

pub fn connect_events(&mut self, tx: EventSender)

Connect the editor’s job channels to the app event channel (TUI only — headless keeps the raw channels for its drains). Late-attaching LSP servers forward through the retained sender.

Source

pub fn handle_app_event(&mut self, ev: AppEvent)

Route one event to its handler (the per-event halves of the old drain loops; the drains call these in a try_recv loop).

Source§

impl Editor

Source

pub fn async_pending(&self) -> bool

Outstanding finite work, independent of whether channels are forwarded.

Source§

impl Editor

Source

pub fn discover_git(&mut self)

Discover the repository for the current buffer. Native work runs on a worker (R6); the pure cached context lands through GitJob::Context and invalidates the git view only when it actually changed. A remote buffer discovers on its endpoint — rev-parse --show-toplevel from the file’s directory, then the context reads — through the bounded remote-execution boundary; the local cwd is never consulted for it (0036 RW8).

Source§

impl Editor

Source

pub fn refresh_hunks(&mut self)

Register the next gutter diff. Render-safe (R6): pure checks and registration only — the diff itself runs on a worker against an immutable text snapshot.

Source

pub fn sign_at(&self, line_1based: usize) -> Option<char>

Gutter sign for a 1-based buffer line: + add, ~ change, - deletion below (0001 pillar 3.1).

Source

pub fn sign_at_staged(&self, line_1based: usize) -> bool

Staged sign (HEAD↔index edge, 0014 wave 4): the line sits inside a staged hunk’s new side. Line alignment between index and live text is approximate when both sets exist — the gutter’s rule: unstaged wins, staged marks what’s already in the index.

Source§

impl Editor

Source

pub fn handle_git_job(&mut self, job: GitJob)

One git job result (TUI events land here directly — 0018; the headless drains call this too).

Source§

impl Editor

Source

pub fn surface(&self) -> Option<&Surface>

Source

pub fn open_delta( &mut self, name: &str, hunks: PreparedDiff, origin: Option<HunkOrigin>, commit: Option<CommitFiles>, )

A diff surface from structured hunks (0010 §2). label heads the stats row; origin is set only for working-tree hunk previews.

Source

pub fn open_log(&mut self, file_scoped: bool)

Space g l: commit browser. Space g h: log scoped to the file.

Source§

impl Editor

Source

pub fn request_open(&mut self, path: PathBuf, intent: OpenIntent)

Source

pub fn request_target(&mut self, target: FileTarget, intent: OpenIntent)

Source

pub fn request_save( &mut self, target: Option<PathBuf>, force: bool, close: bool, )

Source

pub fn handle_io(&mut self, event: IoEvent)

Source

pub fn io_pending(&self) -> bool

Source§

impl Editor

Source

pub fn io_status(&self) -> Option<&'static str>

Source§

impl Editor

Source

pub fn lsp_start_services(&mut self)

Try to attach a language server for the current buffer. The synchronous part only touches in-memory state; discovery (config, root, trust, executability) is owned worker work behind the replay gate. The LSP half of the startup “start services” action: enable attach, then attach for the current buffer. A pure state transition performed identically live and replayed — the tape gates the native discovery inside lsp_maybe_attach.

Source§

impl Editor

Source

pub fn lsp_sync_changed(&mut self)

Source§

impl Editor

Source

pub fn lsp_code_actions_pub(&mut self)

Source

pub fn lsp_document_symbols_pub(&mut self)

Source

pub fn lsp_locations_pub(&mut self, kind: LocKind)

Source

pub fn jump_diagnostic_pub(&mut self, forward: bool)

Source§

impl Editor

Source

pub fn ex_candidates(&self) -> Vec<(&'static str, &'static str)>

Ex-completion candidates for the pending prefix (name, doc).

Source§

impl Editor

Source

pub fn search_pattern(&self) -> Option<&str>

Pending search pattern (incsearch highlight), if any: the / or ? prompt’s body. Pipe and ex bodies never misread as patterns.

Source

pub fn enter_pub(&mut self)

vim Enter: [count] lines down, first non-blank. With the blame gutter on, Enter dives into the line’s commit instead (0011 §3).

Source

pub fn run_motion(&mut self, keys: &str)

Source§

impl Editor

Source

pub fn preview(&self) -> Result<Option<(Vec<Range>, String)>, String>

The live preview: what would the pending keys do right now? The plan the executor would apply — every cursor’s range (0014 wave 3): the preview cannot lie. Query errors surface as Err (the modeline shows them); no operator or no origin means no preview at all.

Source§

impl Editor

Source

pub fn find_candidates(&self) -> Option<FindPending>

Pending f/F/t/T awaiting its char: the leap-style candidates. The WALKER owns that state — the old check read the free-text line’s last byte, so any pattern ending in f/t (/const) lit candidates over the cursor line (issue 13’s “stale match”).

Source

pub fn current_search_query(&self) -> Result<Option<CompiledQuery>, QueryError>

The active query’s identity. Painting consumes its revision-matched worker summary; only grammatical test oracles enumerate all matches.

Source§

impl Editor

Source

pub fn view(&self) -> &Pane

The active pane — the editor’s selections/scroll ARE its state.

Source

pub fn view_mut(&mut self) -> &mut Pane

Source§

impl Editor

Source§

impl Editor

Source

pub fn open_picker(&mut self, kind: Kind)

Source

pub fn close_picker(&mut self)

Close the picker: revoke its active request, stop its worker, and cancel/forget the previews it owns (failed reads become retryable on reopen; successful caches survive).

Source

pub fn picker_open(&self) -> bool

Source§

impl Editor

Source

pub fn register(&self, name: Option<char>) -> &Register

Source§

impl Editor

Source

pub fn paste_bracketed(&mut self, text: &str)

Bracketed paste (0017): one undo unit, no key interpretation — the payload is text, not keystrokes. A live prompt consumes it through the pending reducer; an open picker pastes into its focused field; in normal mode it behaves like p; a trailing newline pastes linewise (vim’s paste plugin convention).

Source§

impl Editor

Source

pub fn remote_write_status(&self) -> Option<&'static str>

Source§

impl Editor

Source

pub fn remote_file(&self) -> Option<&RemoteFile>

Source

pub fn remote_following(&self, document: DocumentId) -> bool

Source§

impl Editor

Source

pub fn visual_range(&self) -> Option<Range>

Source§

impl Editor

Source

pub fn new(buf: Buffer) -> Self

Source

pub fn new_in(buf: Buffer, cwd: PathBuf) -> Self

Pure construction. Native services start explicitly after forensic seeding.

Source

pub fn feed_text(&mut self, text: &str)

Source

pub fn feed(&mut self, key: Key)

Source

pub fn input_normal(&self) -> bool

True when a modal input field sits in normal mode (picker field or pending line) — the TUI draws the block cursor for it.

Source

pub fn pending_sigil(&self) -> Option<char>

The modal line’s sigil when a free-text line is open (: / ? |) — the ONE authority; the render card, the terminal’s bar-cursor shape, and pending dispatch all ask here (a |sed s/a/b/ body is a pipe, not a search).

Source

pub fn mark_rows(&self) -> Vec<(char, usize, String)>

(name, 1-based line, trimmed line text) per set mark, name-sorted — the which-key mark cards’ live rows (0047 §3).

Trait Implementations§

Source§

impl Drop for Editor

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§

§

impl !RefUnwindSafe for Editor

§

impl !Send for Editor

§

impl !Sync for Editor

§

impl !UnwindSafe for Editor

§

impl Freeze for Editor

§

impl Unpin for Editor

§

impl UnsafeUnpin for Editor

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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