@@ -14,6 +14,7 @@ use std::borrow::Cow;
1414
1515use crate::ui::{Prompt, PromptEvent};
1616use helix_core::Position;
17+use helix_view::editor::Action;
1718use helix_view::Editor;
1819
1920pub struct Picker<T> {
@@ -28,14 +29,14 @@ pub struct Picker<T> {
2829 prompt: Prompt,
2930
3031 format_fn: Box<dyn Fn(&T) -> Cow<str>>,
31− callback_fn: Box<dyn Fn(&mut Editor, &T)>,
32+ callback_fn: Box<dyn Fn(&mut Editor, &T, Action)>,
3233}
3334
3435impl<T> Picker<T> {
3536 pub fn new(
3637 options: Vec<T>,
3738 format_fn: impl Fn(&T) -> Cow<str> + 'static,
38− callback_fn: impl Fn(&mut Editor, &T) + 'static,
39+ callback_fn: impl Fn(&mut Editor, &T, Action) + 'static,
3940 ) -> Self {
4041 let prompt = Prompt::new(
4142 "".to_string(),
@@ -133,13 +134,6 @@ impl<T> Component for Picker<T> {
133134 )));
134135
135136 match key_event {
136− // KeyEvent {
137− // code: KeyCode::Char(c),
138− // modifiers: KeyModifiers::NONE,
139− // } => {
140− // self.insert_char(c);
141− // (self.callback_fn)(cx.editor, &self.line, PromptEvent::Update);
142− // }
143137 KeyEvent {
144138 code: KeyCode::Up, ..
145139 }
@@ -165,7 +159,25 @@ impl<T> Component for Picker<T> {
165159 ..
166160 } => {
167161 if let Some(option) = self.selection() {
168− (self.callback_fn)(&mut cx.editor, option);
162+ (self.callback_fn)(&mut cx.editor, option, Action::Replace);
163+ }
164+ return close_fn;
165+ }
166+ KeyEvent {
167+ code: KeyCode::Char('x'),
168+ modifiers: KeyModifiers::CONTROL,
169+ } => {
170+ if let Some(option) = self.selection() {
171+ (self.callback_fn)(&mut cx.editor, option, Action::VerticalSplit);
172+ }
173+ return close_fn;
174+ }
175+ KeyEvent {
176+ code: KeyCode::Char('v'),
177+ modifiers: KeyModifiers::CONTROL,
178+ } => {
179+ if let Some(option) = self.selection() {
180+ (self.callback_fn)(&mut cx.editor, option, Action::HorizontalSplit);
169181 }
170182 return close_fn;
171183 }