pub struct FileSource {
pub root: PathBuf,
pub items: Arc<Mutex<Vec<PathBuf>>>,
/* private fields */
}Expand description
File-source: gitignore-aware cwd walker. Items are paths relative to
root, preview reads from disk capped at PREVIEW_MAX_BYTES with a
binary-byte heuristic.
Bonsai-agnostic — the preview returns just the file contents. The
host (e.g. apps/hjkl) is responsible for layering syntax highlight
spans by reading PickerLogic::preview_path and feeding the
buffer bytes through its own highlighter.
Fields§
§root: PathBuf§items: Arc<Mutex<Vec<PathBuf>>>Implementations§
Trait Implementations§
Source§impl PickerLogic for FileSource
impl PickerLogic for FileSource
Source§fn item_count(&self) -> usize
fn item_count(&self) -> usize
Number of items currently available (grows as enumeration progresses).
Source§fn match_text(&self, idx: usize) -> String
fn match_text(&self, idx: usize) -> String
Text the fuzzy scorer scores against. May equal
label.Source§fn preview(&self, idx: usize) -> (Buffer, String)
fn preview(&self, idx: usize) -> (Buffer, String)
Build the preview pane for the row. Default: empty buffer. Read more
Source§fn preview_path(&self, idx: usize) -> Option<PathBuf>
fn preview_path(&self, idx: usize) -> Option<PathBuf>
File-system path the preview’s content was loaded from, when one
exists. Used by the host to drive language-aware preview rendering
(e.g. tree-sitter syntax highlighting). Default
None for sources
whose preview has no on-disk path (an in-memory snapshot, a help
message, etc.).Source§fn select(&self, _idx: usize) -> PickerAction
fn select(&self, _idx: usize) -> PickerAction
Translate the picked row into an action.
Source§fn requery_mode(&self) -> RequeryMode
fn requery_mode(&self) -> RequeryMode
How the picker should react when the query changes.
Source§fn enumerate(
&mut self,
_query: Option<&str>,
cancel: Arc<AtomicBool>,
) -> Option<JoinHandle<()>>
fn enumerate( &mut self, _query: Option<&str>, cancel: Arc<AtomicBool>, ) -> Option<JoinHandle<()>>
Re-enumerate items. Read more
Source§fn has_preview(&self) -> bool
fn has_preview(&self) -> bool
Whether this source wants the preview pane.
Source§fn preview_top_row(&self, idx: usize) -> usize
fn preview_top_row(&self, idx: usize) -> usize
Initial scroll position (top row) for the preview viewport.
Sources that show a windowed preview around a specific line override
this so the gutter line numbers reflect the actual file line. Default 0.
Source§fn preview_match_row(&self, idx: usize) -> Option<usize>
fn preview_match_row(&self, idx: usize) -> Option<usize>
0-based row to visually mark in the preview (e.g. grep match line).
Default
None → no highlight. Returning Some(row) tells the
renderer to paint a cursor_line_bg across that row.Source§fn preview_line_offset(&self, idx: usize) -> usize
fn preview_line_offset(&self, idx: usize) -> usize
Added to the gutter line numbers in the preview. Sources that
snapshot a window of a larger document (e.g. buffer picker
snapshotting ±N lines around the cursor) use this so the gutter
shows the original document line numbers rather than restarting
at 1. Default 0.
Source§fn handle_key(&self, idx: usize, key: KeyEvent) -> Option<PickerAction>
fn handle_key(&self, idx: usize, key: KeyEvent) -> Option<PickerAction>
Handle a key before the picker’s default handling. Return
Some(action)
to short-circuit and emit that action immediately. Return None to let
the picker handle the key normally. Default: None.Source§fn label_match_positions(
&self,
idx: usize,
query: &str,
label: &str,
) -> Option<Vec<usize>>
fn label_match_positions( &self, idx: usize, query: &str, label: &str, ) -> Option<Vec<usize>>
Override the highlight positions for the row at
idx. Read moreSource§fn preserve_source_order(&self) -> bool
fn preserve_source_order(&self) -> bool
Whether the picker should keep the source’s enumeration order when
the query is empty. Default
false means empty-query rows are sorted
by match-text ascending. Sources that pre-sort meaningfully (e.g. by
recency, by HEAD-first) override to true.Auto Trait Implementations§
impl Freeze for FileSource
impl RefUnwindSafe for FileSource
impl Send for FileSource
impl Sync for FileSource
impl Unpin for FileSource
impl UnsafeUnpin for FileSource
impl UnwindSafe for FileSource
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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