@@ -361,6 +361,14 @@ impl<T: Item + 'static> FilePicker<T> {
361361 self.show_preview = !self.show_preview;
362362 }
363363
364+ fn prompt_handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
365+ if let EventResult::Consumed(_) = self.prompt.handle_event(event, cx) {
366+ // TODO: recalculate only if pattern changed
367+ self.score();
368+ }
369+ EventResult::Consumed(None)
370+ }
371+
364372 fn current_file(&self, editor: &Editor) -> Option<FileLocation> {
365373 self.picker
366374 .selection()
@@ -603,7 +611,77 @@ impl<T: Item + 'static> FilePicker<T> {
603611 return self.handle_idle_timeout(ctx);
604612 }
605613 // TODO: keybinds for scrolling preview
606− self.picker.handle_event(event, ctx)
614+
615+ let key_event = match event {
616+ Event::Key(event) => *event,
617+ Event::Paste(..) => return self.prompt_handle_event(event, ctx),
618+ Event::Resize(..) => return EventResult::Consumed(None),
619+ _ => return EventResult::Ignored(None),
620+ };
621+
622+ let close_fn =
623+ EventResult::Consumed(Some(Box::new(|compositor: &mut Compositor, _ctx| {
624+ // remove the layer
625+ compositor.last_picker = compositor.pop();
626+ })));
627+
628+ // So that idle timeout retriggers
629+ ctx.editor.reset_idle_timer();
630+
631+ match key_event {
632+ shift!(Tab) | key!(Up) | ctrl!('p') => {
633+ self.move_by(1, Direction::Backward);
634+ }
635+ key!(Tab) | key!(Down) | ctrl!('n') => {
636+ self.move_by(1, Direction::Forward);
637+ }
638+ key!(PageDown) | ctrl!('d') => {
639+ self.page_down();
640+ }
641+ key!(PageUp) | ctrl!('u') => {
642+ self.page_up();
643+ }
644+ key!(Home) => {
645+ self.to_start();
646+ }
647+ key!(End) => {
648+ self.to_end();
649+ }
650+ key!(Esc) | ctrl!('c') => {
651+ return close_fn;
652+ }
653+ alt!(Enter) => {
654+ if let Some(option) = self.selection() {
655+ (self.callback_fn)(ctx, option, Action::Load);
656+ }
657+ }
658+ key!(Enter) => {
659+ if let Some(option) = self.selection() {
660+ (self.callback_fn)(ctx, option, Action::Replace);
661+ }
662+ return close_fn;
663+ }
664+ ctrl!('s') => {
665+ if let Some(option) = self.selection() {
666+ (self.callback_fn)(ctx, option, Action::HorizontalSplit);
667+ }
668+ return close_fn;
669+ }
670+ ctrl!('v') => {
671+ if let Some(option) = self.selection() {
672+ (self.callback_fn)(ctx, option, Action::VerticalSplit);
673+ }
674+ return close_fn;
675+ }
676+ ctrl!('t') => {
677+ self.toggle_preview();
678+ }
679+ _ => {
680+ self.prompt_handle_event(event, ctx);
681+ }
682+ }
683+
684+ EventResult::Consumed(None)
607685 }
608686
609687 fn cursor(&self, area: Rect, ctx: &Editor) -> (Option<Position>, CursorKind) {
@@ -737,11 +815,7 @@ impl<T: Item> Picker<T> {
737815 }
738816
739817 fn prompt_handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
740− if let EventResult::Consumed(_) = self.prompt.handle_event(event, cx) {
741− // TODO: recalculate only if pattern changed
742− self.score();
743− }
744− EventResult::Consumed(None)
818+ unimplemented!()
745819 }
746820}
747821
@@ -757,75 +831,7 @@ impl<T: Item + 'static> Component for Picker<T> {
757831 }
758832
759833 fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
760− let key_event = match event {
761− Event::Key(event) => *event,
762− Event::Paste(..) => return self.prompt_handle_event(event, cx),
763− Event::Resize(..) => return EventResult::Consumed(None),
764− _ => return EventResult::Ignored(None),
765− };
766−
767− let close_fn = EventResult::Consumed(Some(Box::new(|compositor: &mut Compositor, _cx| {
768− // remove the layer
769− compositor.last_picker = compositor.pop();
770− })));
771−
772− // So that idle timeout retriggers
773− cx.editor.reset_idle_timer();
774−
775− match key_event {
776− shift!(Tab) | key!(Up) | ctrl!('p') => {
777− self.move_by(1, Direction::Backward);
778− }
779− key!(Tab) | key!(Down) | ctrl!('n') => {
780− self.move_by(1, Direction::Forward);
781− }
782− key!(PageDown) | ctrl!('d') => {
783− self.page_down();
784− }
785− key!(PageUp) | ctrl!('u') => {
786− self.page_up();
787− }
788− key!(Home) => {
789− self.to_start();
790− }
791− key!(End) => {
792− self.to_end();
793− }
794− key!(Esc) | ctrl!('c') => {
795− return close_fn;
796− }
797− alt!(Enter) => {
798− if let Some(option) = self.selection() {
799− (self.callback_fn)(cx, option, Action::Load);
800− }
801− }
802− key!(Enter) => {
803− if let Some(option) = self.selection() {
804− (self.callback_fn)(cx, option, Action::Replace);
805− }
806− return close_fn;
807− }
808− ctrl!('s') => {
809− if let Some(option) = self.selection() {
810− (self.callback_fn)(cx, option, Action::HorizontalSplit);
811− }
812− return close_fn;
813− }
814− ctrl!('v') => {
815− if let Some(option) = self.selection() {
816− (self.callback_fn)(cx, option, Action::VerticalSplit);
817− }
818− return close_fn;
819− }
820− ctrl!('t') => {
821− self.toggle_preview();
822− }
823− _ => {
824− self.prompt_handle_event(event, cx);
825− }
826− }
827−
828− EventResult::Consumed(None)
834+ unimplemented!()
829835 }
830836
831837 fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) {