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: PathBufThe 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.