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§
Source§impl FilePickSource
impl FilePickSource
pub fn new() -> FilePickSource
Trait Implementations§
Source§impl Default for FilePickSource
impl Default for FilePickSource
Source§fn default() -> FilePickSource
fn default() -> 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],
) -> Result<PickerInitResult, String>
fn init( &self, ctx: &PickerContext<'_>, args: &[String], ) -> Result<PickerInitResult, String>
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,
) -> Result<PickerAcceptOutcome, String>
fn accept( &self, _ctx: &PickerContext<'_>, routing: &RoutingPayload, ) -> Result<PickerAcceptOutcome, String>
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<Pin<Box<dyn Future<Output = Result<PickerAcceptOutcome, String>> + Send>>>
fn accept_async( &self, _ctx: &PickerContext<'_>, _routing: &RoutingPayload, ) -> Option<Pin<Box<dyn Future<Output = Result<PickerAcceptOutcome, String>> + Send>>>
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<Result<PickerInitResult, String>>
fn on_query_changed( &self, _ctx: &PickerContext<'_>, _query: &str, ) -> Option<Result<PickerInitResult, String>>
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 moreSource§fn initial_query(&self, _args: &[String]) -> Option<String>
fn initial_query(&self, _args: &[String]) -> Option<String>
Source§fn preview(
&self,
_ctx: &PickerContext<'_>,
_routing: &RoutingPayload,
) -> Option<PickerPreviewOutcome>
fn preview( &self, _ctx: &PickerContext<'_>, _routing: &RoutingPayload, ) -> Option<PickerPreviewOutcome>
Source§fn preview_debounce(&self) -> Option<Duration>
fn preview_debounce(&self) -> Option<Duration>
Auto Trait Implementations§
impl Freeze for FilePickSource
impl RefUnwindSafe for FilePickSource
impl Send for FilePickSource
impl Sync for FilePickSource
impl Unpin for FilePickSource
impl UnsafeUnpin for FilePickSource
impl UnwindSafe for FilePickSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more