@@ -312,6 +312,55 @@ impl<T: Item + 'static> FilePicker<T> {
312 self.matches.sort_unstable();
312 self.matches.sort_unstable();
315+ /// Move the cursor by a number of lines, either down (`Forward`) or up (`Backward`)
316+ pub fn move_by(&mut self, amount: usize, direction: Direction) {
317+ let len = self.matches.len();
320+ // No results, can't move.
325+ Direction::Forward => {
326+ self.cursor = self.cursor.saturating_add(amount) % len;
328+ Direction::Backward => {
329+ self.cursor = self.cursor.saturating_add(len).saturating_sub(amount) % len;
334+ /// Move the cursor down by exactly one page. After the last page comes the first page.
335+ pub fn page_up(&mut self) {
336+ self.move_by(self.completion_height as usize, Direction::Backward);
339+ /// Move the cursor up by exactly one page. After the first page comes the last page.
340+ pub fn page_down(&mut self) {
341+ self.move_by(self.completion_height as usize, Direction::Forward);
344+ /// Move the cursor to the first entry
345+ pub fn to_start(&mut self) {
349+ /// Move the cursor to the last entry
350+ pub fn to_end(&mut self) {
351+ self.cursor = self.matches.len().saturating_sub(1);
354+ pub fn selection(&self) -> Option<&T> {
357+ .map(|pmatch| &self.options[pmatch.index])
360+ pub fn toggle_preview(&mut self) {
361+ self.show_preview = !self.show_preview;
315 fn current_file(&self, editor: &Editor) -> Option<FileLocation> {
364 fn current_file(&self, editor: &Editor) -> Option<FileLocation> {
316 self.picker
365 self.picker
317 .selection()
366 .selection()
@@ -656,51 +705,35 @@ impl<T: Item> Picker<T> {
657 /// Move the cursor by a number of lines, either down (`Forward`) or up (`Backward`)
706 /// Move the cursor by a number of lines, either down (`Forward`) or up (`Backward`)
658 pub fn move_by(&mut self, amount: usize, direction: Direction) {
707 pub fn move_by(&mut self, amount: usize, direction: Direction) {
659− let len = self.matches.len();
708+ unimplemented!()
662− // No results, can't move.
667− Direction::Forward => {
668− self.cursor = self.cursor.saturating_add(amount) % len;
670− Direction::Backward => {
671− self.cursor = self.cursor.saturating_add(len).saturating_sub(amount) % len;
676 /// Move the cursor down by exactly one page. After the last page comes the first page.
711 /// Move the cursor down by exactly one page. After the last page comes the first page.
677 pub fn page_up(&mut self) {
712 pub fn page_up(&mut self) {
678− self.move_by(self.completion_height as usize, Direction::Backward);
713+ unimplemented!()
681 /// Move the cursor up by exactly one page. After the first page comes the last page.
716 /// Move the cursor up by exactly one page. After the first page comes the last page.
682 pub fn page_down(&mut self) {
717 pub fn page_down(&mut self) {
683− self.move_by(self.completion_height as usize, Direction::Forward);
718+ unimplemented!()
686 /// Move the cursor to the first entry
721 /// Move the cursor to the first entry
687 pub fn to_start(&mut self) {
722 pub fn to_start(&mut self) {
688− self.cursor = 0;
723+ unimplemented!()
691 /// Move the cursor to the last entry
726 /// Move the cursor to the last entry
692 pub fn to_end(&mut self) {
727 pub fn to_end(&mut self) {
693− self.cursor = self.matches.len().saturating_sub(1);
728+ unimplemented!()
696 pub fn selection(&self) -> Option<&T> {
731 pub fn selection(&self) -> Option<&T> {
697− self.matches
732+ unimplemented!()
699− .map(|pmatch| &self.options[pmatch.index])
702 pub fn toggle_preview(&mut self) {
735 pub fn toggle_preview(&mut self) {
703− self.show_preview = !self.show_preview;
736+ unimplemented!()
706 fn prompt_handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
739 fn prompt_handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {