Skip to main content

PickerContext

Struct PickerContext 

Source
pub struct PickerContext<'a> {
    pub active_buffer: ActiveBufferSnapshot<'a>,
    pub workspace_root: PathBuf,
    pub recent_files: &'a [PathBuf],
    pub position_history: Vec<PositionEntry>,
    pub buffers: Vec<BufferEntry>,
    pub marks: Vec<(char, Position)>,
    pub registers: Vec<(String, String)>,
    pub yank_ring: Vec<(String, bool)>,
    pub active_modes: Vec<Arc<str>>,
    pub command_history: Vec<String>,
    pub search_history: Vec<String>,
    pub pane_buffer_history: Vec<PaneHistoryRow>,
}
Expand description

Snapshot the host passes to PickerSourceGenerator::init (and accept) on each picker invocation.

Sources access the borrowed fields directly during the synchronous prelude; the moment init returns, the borrow is released and any captured async work owns its own clones.

Fields§

§active_buffer: ActiveBufferSnapshot<'a>§workspace_root: PathBuf

The active buffer’s project root (PR.4), resolved by the host through ProjectResolverHandle::for_path.

NOT the process working directory, and not the active document’s parent — both were tried and both were wrong in opposite directions. The parent “behaved unintuitively for projects spread across many subdirectories”; the cwd is right only if you launched the editor inside the tree you are editing. A source wanting “where does this file’s project live” reads this and needs nothing else.

Degrades to the process cwd (then .) only when no ProjectResolverHandle is registered — a test harness, not a real boot. Owned because that fallback is fallible and the PathBuf needs somewhere stable to live.

§recent_files: &'a [PathBuf]§position_history: Vec<PositionEntry>

Position-history ring, translated from the App’s richer PositionEntry (which carries BufferKind) to this crate’s picker-friendly view. Owned vec because the translation step produces fresh entries – consistent with buffers / marks / registers below.

§buffers: Vec<BufferEntry>§marks: Vec<(char, Position)>§registers: Vec<(String, String)>

Registers as (name, contents) pairs, with the full contents.

It used to carry a 40-char preview with newlines replaced by \u{21B5}, which was harmless while the only consumer routed PasteRegister { name } and the host re-read the register itself. yank-ring returns the text directly, so a preview here meant picking a long register inserted a truncation — and one with ↵ where its newlines had been, so corrupt rather than merely short.

Consumers truncate for display; only display should be lossy.

§yank_ring: Vec<(String, bool)>

YR.4: the yank ring, newest first, as (content, linewise) pairs.

The full content, not a preview — the picker’s accept has to return the real text, and truncating here would mean pasting a truncation. registers above carries previews because its accept is PasteRegister { name }, which re-reads the register host-side rather than carrying its text.

linewise rides along because a linewise and a charwise entry paste differently, and a picker that hides that makes paste unpredictable exactly when the user is choosing between two similar-looking rows.

§active_modes: Vec<Arc<str>>

MARG.3 (2026-07-15): active minor+major mode names for the current buffer. The command completion margin uses this to filter out keybindings whose source minor/major mode is not currently active (see [KeybindingSource::Mode]).

§command_history: Vec<String>

MB.3: the App’s command-line history ring (command_history), oldest-first as stored host-side. The history picker source (q: / :history) walks this reversed (newest first) and <CR> loads the chosen entry into the : line without executing. Owned vec, rebuilt per picker-open like the other snapshot fields.

§search_history: Vec<String>

MB.5: the App’s search-line history ring (search_history), oldest-first as stored host-side. The search-history picker source (q/ / q? / :history search) walks this reversed (newest first) and <CR> loads the chosen entry into the / search line without executing.

§pane_buffer_history: Vec<PaneHistoryRow>

PBH.5: the ACTIVE pane’s buffer trail, oldest-first, as (label, is_current) per entry. The pane-buffer-history source (:history pane-buffers) walks this reversed so the most recent stop is on top, and marks the entry the walk cursor is currently on.

Per-pane by construction: the host snapshots only the active pane’s trail, so the picker cannot accidentally show a global or cross-pane view.

Auto Trait Implementations§

§

impl<'a> Freeze for PickerContext<'a>

§

impl<'a> RefUnwindSafe for PickerContext<'a>

§

impl<'a> Send for PickerContext<'a>

§

impl<'a> Sync for PickerContext<'a>

§

impl<'a> Unpin for PickerContext<'a>

§

impl<'a> UnsafeUnpin for PickerContext<'a>

§

impl<'a> UnwindSafe for PickerContext<'a>

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.

§

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.

§

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