pub enum RoutingPayload {
Show 24 variants
Buffer {
id: u32,
},
PaneHistoryEntry {
index: u32,
},
ResolveDiff {
primary: u32,
accept: bool,
},
LspInstance {
server_id: String,
workspace: PathBuf,
},
AiSession {
provider: String,
index: u32,
},
LspLocation {
path: PathBuf,
line: u32,
col: u32,
},
LspCompletion {
index: u32,
},
LspCodeAction {
index: u32,
},
OpenFile {
path: PathBuf,
},
JumpInBuffer {
buffer_id: u32,
line: u32,
col: u32,
},
InvokeCommand {
id: String,
args: Args,
},
PasteRegister {
name: char,
},
JumpToMark {
name: char,
},
ExpandSnippet {
id: String,
},
AcceptShowMessageAction {
request_id: u32,
action_index: u32,
},
LspCodeLens {
index: u32,
},
ColorPresentation {
index: u32,
},
Colorscheme {
name: String,
},
LoadCommandLine {
text: String,
},
LoadSearchLine {
text: String,
},
BranchBase {
name: String,
},
SuppliedValue {
value: String,
},
FileLocation {
path: PathBuf,
line: u32,
col: u32,
},
Create {
query: String,
},
}Expand description
Typed payload the picker accept dispatch reads to figure out
which side effect to run. Replaces the tab-encoded string
payloads stuffed into RawCandidate.text in earlier phases
(Phase 4.2.g.7 polish).
One variant per PickerAction; the variant naturally
communicates the dispatch path AND carries the typed data the
handler needs (no string parsing, no fragility around \t in
paths). The PickerAction tag stays for now – the App’s
dispatch matches on it first to choose the code path; future
cleanup could pivot to matching on the payload variant alone
since the two always agree, but the redundancy is harmless.
Variants§
Buffer
PickerAction::SwitchToBuffer – the host’s buffer id
(newtype-wrapped u32 host-side; we hold the raw value
to keep the picker module renderer-agnostic).
PaneHistoryEntry
PBH.5: one entry in the ACTIVE pane’s buffer trail, identified by its index rather than its buffer id — the same buffer can appear at several points in a trail, and picking the third stop must land on the third stop.
Accepting moves the walk cursor rather than pushing a visit: the
picker is random access over the existing trail, not a new
navigation. Pushing would append a duplicate and make <C-7>
unreachable, exactly as an unsuppressed walk would.
ResolveDiff
Resolve a specific pending diff review by its primary buffer id with
Accept (accept = true) or Reject. Emitted by the diff-review picker
(:diff-accept / :diff-reject with >1 pending review) so the user
chooses WHICH diff to resolve. primary is the raw host BufferId.
LspInstance
PickerAction::OpenLspLog / OpenLspTraceLog – the
supervisor key. workspace rides for completeness but
today’s handlers only use server_id.
AiSession
PickerAction::OpenAiLog – the AI session key (provider +
per-provider index) the host reconstructs into a
SessionKey to open *ai:<provider>:<index>*. Ephemeral
(sessions come and go), so routing_identity returns
None — no MRU recency.
LspLocation
PickerAction::JumpToLspLocation – canonical (path, line, col) the host’s jump_to_file_line_col consumes.
LSP 0-based line + utf-8 byte column; the host already
converted these utf-8 host-side at ingestion time.
LspCompletion
PickerAction::AcceptLspCompletion – numeric index into
the host’s pending_completion_items snapshot.
LspCodeAction
PickerAction::AcceptLspCodeAction – numeric index into
the host’s pending_code_action_items snapshot.
OpenFile
PickerAction::OpenFile – canonical filesystem path the
accept dispatch hands to App::do_edit(Some(path), false). Used by the file picker (:files) and the
recent-files picker; directories defer to oil/file-tree
the same way :e DIR does.
JumpInBuffer
PickerAction::JumpInBuffer – jump to (line, col) in
an already-registered buffer. Captured at picker-open
time so the destination is stable even if the user
arrowed through another picker’s hover-preview.
Emitted by :picker lines, :picker jumps (for entries
pointing at currently-open buffers), and – once
migrated – :picker marks. MRU returns None for this
variant because (line, col) drift as the buffer is
edited; a stale identity would mis-rank candidates.
InvokeCommand
Invoke an ex-command by stable id. Emitted by the
command palette (:picker commands); the host resolves
id against its CommandRegistry, builds a
CommandInvocation, and routes through the same
dispatcher the : line uses. args carries any
pre-supplied positional arguments (the command palette
today emits Args::None; future “pick a thing, then
run a command on it” flows will carry richer values).
PasteRegister
Paste a named register’s contents at the cursor.
Emitted by :picker registers; name is the single-
char register identifier (a..z, 0..9, +,
", etc.). The host’s apply_picker_outcome::PasteRegister
arm sets the pending register and runs the normal paste
path so charwise / linewise / blockwise distinction is
honored.
JumpToMark
Jump to a named mark (mX). Emitted by :picker marks.
The host resolves the mark to a position via its
existing do_jump_mark path so the cursor placement +
position-history push match the keyboard-driven
behavior. name carries a stable identity, so MRU
will record mark:<name> once slice 14 lands.
ExpandSnippet
Expand a snippet by name at the cursor. Emitted by
:picker snippets. The host resolves the body through
SnippetRegistry::by_name and routes through the
existing :snippet-expand path. MRU keys on
snip:<name>.
AcceptShowMessageAction
Accept one action from a server-initiated
window/showMessageRequest. request_id keys into the
App’s lsp_pending_show_message_requests map (the slot
that holds the inbound oneshot); action_index selects
which MessageActionItem from the request’s actions
vec ferries back to the server. Dismiss (Esc) routes
through do_picker_dismiss which replies null (i.e.
the user closed the prompt without picking).
LspCodeLens
4.5.d – PickerAction::AcceptLspCodeLens. Numeric
index into the host’s pending_code_lens_items
snapshot (a clone of the active buffer’s code-lens
cache at picker-open time). The accept dispatch
resolves the lens (if it arrived without a command)
and routes the resulting command through
workspace/executeCommand on the originating server.
ColorPresentation
4.5.e – PickerAction::AcceptColorPresentation.
Numeric index into the host’s
pending_color_presentations snapshot. Accept splices
the chosen ColorPresentation.text_edit (or label
fallback) into the buffer at the cached color range.
Colorscheme
T.12: the theme name a colorscheme-picker candidate carries.
Both accept and live-preview resolve the name against the
ThemeRegistry catalog and swap the active theme.
LoadCommandLine
MB.3: the past command a history-picker candidate carries.
Accept loads text into the editable : line via the
host’s open_command_line seam — it does not execute
(the user tweaks / <C-x><C-e>s it, then <CR>s). Emitted
by the history picker source (q: / :history).
Ephemeral by nature — routing_identity returns None, so
no MRU recency (the history ring is already recency-ordered).
LoadSearchLine
MB.5: load text into the editable / search line. Emitted
by the search-history picker source (q/ / q? /
:history search). The host opens the *search-line* buffer
with Forward direction and seeds the pattern; the user tweaks
it, then <CR> to execute. Ephemeral — no MRU recency.
BranchBase
The branch name a base-branch-picker candidate carries.
Emitted by magit’s branch-create wizard (c in
magit-branch-mode): the user picks an existing branch as the
base, then accept opens a follow-up text prompt for the new
branch’s name (PickerAcceptOutcome::OpenPrompt, stashing
this name in the prompt buffer’s synthetic name).
SuppliedValue
MG.53.e: a plain value the picked candidate stands for, for a source that answers a question rather than performing an action.
Carried by file-pick and consumed by whatever parked itself
waiting for a value — today a picker-backed transient argument.
The source does not know what the value is for, which is the
point: one registered file listing serves every argument that
names a file.
FileLocation
OR.6: a place in a file on disk — (path, line, col).
The peer PickerAcceptOutcome::JumpToLocation already had and the
routing side lacked. Without it a source whose rows stand for positions
in files can only carry Self::OpenFile, which drops the line — so a
row for a heading halfway down a file lands at the top of it. Org-roam’s
headline nodes are 19% of its corpus and every one of them lands wrong
without this.
Distinct from Self::LspLocation, which is the same shape under a
name that says where it came from. Reusing it would have worked and read
as a lie in every source that is not an LSP result.
No MRU identity: a location is not an identity — the same line means something different after an edit above it.
Create
OR.5: the query the user typed, carried by the picker’s synthetic create row — the offer to make the thing they were looking for and did not find.
Emitted by the picker itself rather than by a source: a source declares
create_label on its spec and the picker appends the row, so every
source gets the behaviour from one declaration and none of them
re-implements it. accept routes back to the source, which decides what
creation means — org-roam mints a node, another source might make a file
or a branch. The picker never knows.
query is verbatim, spaces and non-ASCII included. The source is
creating something the user named, so trimming or normalising here
would be the picker having an opinion about a namespace it does not own.
Implementations§
Source§impl RoutingPayload
impl RoutingPayload
Sourcepub fn error_location(
&self,
resolver: &dyn BufferPathResolver,
) -> Option<ErrorLocation>
pub fn error_location( &self, resolver: &dyn BufferPathResolver, ) -> Option<ErrorLocation>
Where this entry points, when it points into a file on disk — the picker’s own translation of a row into an error-list location.
This is what makes <C-q> (send-to-error-list) generic over every
picker: the host no longer decides which payloads have a location,
the payload does. A plugin picker that emits Self::FileLocation
across the WIT boundary gets error-list support for free, without the
host learning about it.
Exhaustive by construction — there is deliberately no _ arm. Every
variant decides here: a location (and how), or None (a register, a
command, a buffer id — nothing to jump to). A new payload variant will
not compile until it declares its mapping. The earlier host-side match
carried a wildcard and silently dropped Self::FileLocation, so a
plugin picker’s file rows sent nothing; folding coverage into the type
turns that silent gap into a compile error.
Trait Implementations§
Source§impl Clone for RoutingPayload
impl Clone for RoutingPayload
Source§fn clone(&self) -> RoutingPayload
fn clone(&self) -> RoutingPayload
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more