@@ -114,7 +114,7 @@ impl Preview<'_, '_> {
114114 }
115115}
116116
117−pub struct FilePicker<T: Item> {
117+pub struct Picker<T: Item> {
118118 options: Vec<T>,
119119 editor_data: T::Data,
120120 // filter: String,
@@ -135,7 +135,6 @@ pub struct FilePicker<T: Item> {
135135
136136 callback_fn: PickerCallback<T>,
137137
138− picker: Picker<T>,
139138 pub truncate_start: bool,
140139 /// Caches paths to documents
141140 preview_cache: HashMap<PathBuf, CachedPreview>,
@@ -144,7 +143,7 @@ pub struct FilePicker<T: Item> {
144143 file_fn: Option<FileCallback<T>>,
145144}
146145
147−impl<T: Item + 'static> FilePicker<T> {
146+impl<T: Item + 'static> Picker<T> {
148147 pub fn new(
149148 options: Vec<T>,
150149 editor_data: T::Data,
@@ -173,8 +172,6 @@ impl<T: Item + 'static> FilePicker<T> {
173172 preview_cache: HashMap::new(),
174173 read_buffer: Vec::with_capacity(1024),
175174 file_fn: None,
176−
177− picker: unimplemented!(),
178175 };
179176
180177 picker.calculate_column_widths();
@@ -197,7 +194,6 @@ impl<T: Item + 'static> FilePicker<T> {
197194
198195 pub fn truncate_start(mut self, truncate_start: bool) -> Self {
199196 self.truncate_start = truncate_start;
200− self.picker.truncate_start = truncate_start;
201197 self
202198 }
203199
@@ -377,8 +373,7 @@ impl<T: Item + 'static> FilePicker<T> {
377373 }
378374
379375 fn current_file(&self, editor: &Editor) -> Option<FileLocation> {
380− self.picker
381− .selection()
376+ self.selection()
382377 .and_then(|current| (self.file_fn.as_ref()?)(editor, current))
383378 .and_then(|(path_or_id, line)| path_or_id.get_canonicalized().ok().zip(Some(line)))
384379 }
@@ -849,13 +844,9 @@ impl<T: Item + 'static> FilePicker<T> {
849844 self.completion_height = height.saturating_sub(4);
850845 Some((width, height))
851846 }
852−
853− fn id(&self) -> Option<&'static str> {
854− Some("file-picker")
855− }
856847}
857848
858−impl<T: Item + 'static> Component for FilePicker<T> {
849+impl<T: Item + 'static> Component for Picker<T> {
859850 fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) {
860851 // +---------+ +---------+
861852 // |prompt | |preview |
@@ -864,7 +855,7 @@ impl<T: Item + 'static> Component for FilePicker<T> {
864855 // | | | |
865856 // +---------+ +---------+
866857
867− let render_preview = self.picker.show_preview && area.width > MIN_AREA_WIDTH_FOR_PREVIEW;
858+ let render_preview = self.show_preview && area.width > MIN_AREA_WIDTH_FOR_PREVIEW;
868859
869860 let picker_width = if render_preview {
870861 area.width / 2
@@ -909,112 +900,6 @@ impl Ord for PickerMatch {
909900
910901type PickerCallback<T> = Box<dyn Fn(&mut Context, &T, Action)>;
911902
912−pub struct Picker<T: Item> {
913− options: Vec<T>,
914− editor_data: T::Data,
915− // filter: String,
916− matcher: Box<Matcher>,
917− matches: Vec<PickerMatch>,
918−
919− /// Current height of the completions box
920− completion_height: u16,
921−
922− cursor: usize,
923− // pattern: String,
924− prompt: Prompt,
925− previous_pattern: (String, FuzzyQuery),
926− /// Whether to truncate the start (default true)
927− pub truncate_start: bool,
928− /// Whether to show the preview panel (default true)
929− show_preview: bool,
930− /// Constraints for tabular formatting
931− widths: Vec<Constraint>,
932−
933− callback_fn: PickerCallback<T>,
934−}
935−
936−impl<T: Item> Picker<T> {
937− pub fn new(
938− options: Vec<T>,
939− editor_data: T::Data,
940− callback_fn: impl Fn(&mut Context, &T, Action) + 'static,
941− ) -> Self {
942− unimplemented!()
943− }
944−
945− pub fn set_options(&mut self, new_options: Vec<T>) {
946− unimplemented!()
947− }
948−
949− pub fn score(&mut self) {
950− unimplemented!()
951− }
952−
953− pub fn force_score(&mut self) {
954− unimplemented!()
955− }
956−
957− /// Move the cursor by a number of lines, either down (`Forward`) or up (`Backward`)
958− pub fn move_by(&mut self, amount: usize, direction: Direction) {
959− unimplemented!()
960− }
961−
962− /// Move the cursor down by exactly one page. After the last page comes the first page.
963− pub fn page_up(&mut self) {
964− unimplemented!()
965− }
966−
967− /// Move the cursor up by exactly one page. After the first page comes the last page.
968− pub fn page_down(&mut self) {
969− unimplemented!()
970− }
971−
972− /// Move the cursor to the first entry
973− pub fn to_start(&mut self) {
974− unimplemented!()
975− }
976−
977− /// Move the cursor to the last entry
978− pub fn to_end(&mut self) {
979− unimplemented!()
980− }
981−
982− pub fn selection(&self) -> Option<&T> {
983− unimplemented!()
984− }
985−
986− pub fn toggle_preview(&mut self) {
987− unimplemented!()
988− }
989−
990− fn prompt_handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
991− unimplemented!()
992− }
993−}
994−
995−// process:
996−// - read all the files into a list, maxed out at a large value
997−// - on input change:
998−// - score all the names in relation to input
999−
1000−impl<T: Item + 'static> Component for Picker<T> {
1001− fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
1002− unimplemented!()
1003− }
1004−
1005− fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
1006− unimplemented!()
1007− }
1008−
1009− fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) {
1010− unimplemented!()
1011− }
1012−
1013− fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
1014− unimplemented!()
1015− }
1016−}
1017−
1018903/// Returns a new list of options to replace the contents of the picker
1019904/// when called with the current picker query,
1020905pub type DynQueryCallback<T> =
@@ -1023,7 +908,7 @@ pub type DynQueryCallback<T> =
1023908/// A picker that updates its contents via a callback whenever the
1024909/// query string changes. Useful for live grep, workspace symbols, etc.
1025910pub struct DynamicPicker<T: ui::menu::Item + Send> {
1026− file_picker: FilePicker<T>,
911+ file_picker: Picker<T>,
1027912 query_callback: DynQueryCallback<T>,
1028913 query: String,
1029914}
@@ -1031,7 +916,7 @@ pub struct DynamicPicker<T: ui::menu::Item + Send> {
1031916impl<T: ui::menu::Item + Send> DynamicPicker<T> {
1032917 pub const ID: &'static str = "dynamic-picker";
1033918
1034− pub fn new(file_picker: FilePicker<T>, query_callback: DynQueryCallback<T>) -> Self {
919+ pub fn new(file_picker: Picker<T>, query_callback: DynQueryCallback<T>) -> Self {
1035920 Self {
1036921 file_picker,
1037922 query_callback,
@@ -1047,7 +932,7 @@ impl<T: Item + Send + 'static> Component for DynamicPicker<T> {
1047932
1048933 fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
1049934 let event_result = self.file_picker.handle_event(event, cx);
1050− let current_query = self.file_picker.picker.prompt.line();
935+ let current_query = self.file_picker.prompt.line();
1051936
1052937 if !matches!(event, Event::IdleTimeout) || self.query == *current_query {
1053938 return event_result;
@@ -1063,7 +948,7 @@ impl<T: Item + Send + 'static> Component for DynamicPicker<T> {
1063948 // Wrapping of pickers in overlay is done outside the picker code,
1064949 // so this is fragile and will break if wrapped in some other widget.
1065950 let picker = match compositor.find_id::<Overlay<DynamicPicker<T>>>(Self::ID) {
1066− Some(overlay) => &mut overlay.content.file_picker.picker,
951+ Some(overlay) => &mut overlay.content.file_picker,
1067952 None => return,
1068953 };
1069954 picker.set_options(new_options);