pub struct FilePickSource {
pub spec: PickerSourceSpec,
}Expand description
:picker file-pick [root]. MG.53.e — the same walk as
FilesSource, accepting to a value instead of to an open
buffer.
The two differ only in what accept means, and that difference is the
whole reason this exists: FilesSource hands its path to do_edit,
i.e. it opens the file, where a caller asking “which file?” needs the
path itself. magit’s File (repo-relative): argument was a free-text
prompt because of that one mismatch — the listing was always
reusable, the accept never was.
The path is emitted relative to the walk root, because the consumers are git commands and git addresses files repo-relatively. An absolute path would work by luck for the common case (the root is the repo) and break the moment it is not.
Registered in the host rather than in lattice-magit so every
provider wanting “choose a file, then act” reaches it through the
same PickerSourceSpec surface, including WASM ones. A magit-local
copy would have put a second consumer of the repo file walk inside a
feature crate and bought nothing but a smaller diff.
Fields§
§spec: PickerSourceSpecImplementations§
Trait Implementations§
Source§impl Default for FilePickSource
impl Default for FilePickSource
Source§impl PickerSourceGenerator for FilePickSource
impl PickerSourceGenerator for FilePickSource
Source§fn spec(&self) -> &PickerSourceSpec
fn spec(&self) -> &PickerSourceSpec
:describe-picker /
:picker <Tab> listings without cloning.Source§fn init(
&self,
ctx: &PickerContext<'_>,
args: &[String],
) -> SourceResult<PickerInitResult>
fn init( &self, ctx: &PickerContext<'_>, args: &[String], ) -> SourceResult<PickerInitResult>
ctx, clone into async captures if
necessary, return the appropriate PickerInitResult
variant. Synchronous errors (no active buffer when
one was required, args validation failure) return
Err; the host echoes the error and leaves the
picker closed. Read moreSource§fn accept(
&self,
_ctx: &PickerContext<'_>,
routing: &RoutingPayload,
) -> SourceResult<PickerAcceptOutcome>
fn accept( &self, _ctx: &PickerContext<'_>, routing: &RoutingPayload, ) -> SourceResult<PickerAcceptOutcome>
PickerAcceptOutcome the host applies. The
generator owns the mapping from its emitted
routing-payload variant(s) to outcome(s); mismatch
returns Err, which the host echoes.Source§fn accept_async(
&self,
_ctx: &PickerContext<'_>,
_routing: &RoutingPayload,
) -> Option<AcceptFuture>
fn accept_async( &self, _ctx: &PickerContext<'_>, _routing: &RoutingPayload, ) -> Option<AcceptFuture>
None means “this source resolves accept
synchronously” — every native source takes this path and is unchanged. Read moreSource§fn on_query_changed(
&self,
_ctx: &PickerContext<'_>,
_query: &str,
) -> Option<SourceResult<PickerInitResult>>
fn on_query_changed( &self, _ctx: &PickerContext<'_>, _query: &str, ) -> Option<SourceResult<PickerInitResult>>
None means “static source –
host uses fuzzy refilter over the candidate set
returned by init”. Returning Some(result) from a
source whose spec().live == true replaces the
picker’s candidate set wholesale; the host wires up
debouncing and cancels any in-flight invocation when a
fresh query arrives. Read moreSource§fn descend(
&self,
_ctx: &PickerContext<'_>,
_candidate: &RawCandidate,
) -> Option<String>
fn descend( &self, _ctx: &PickerContext<'_>, _candidate: &RawCandidate, ) -> Option<String>
<C-l> — refine the query from the selected candidate instead
of accepting it. Read more<CR> on a row that is a SIGNPOST rather than a destination. Read more