@@ -14,6 +14,7 @@ use std::borrow::Cow;
15use crate::ui::{Prompt, PromptEvent};
15use crate::ui::{Prompt, PromptEvent};
16use helix_core::Position;
16use helix_core::Position;
17+use helix_view::editor::Action;
17use helix_view::Editor;
18use helix_view::Editor;
19pub struct Picker<T> {
20pub struct Picker<T> {
@@ -28,14 +29,14 @@ pub struct Picker<T> {
28 prompt: Prompt,
29 prompt: Prompt,
30 format_fn: Box<dyn Fn(&T) -> Cow<str>>,
31 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)>,
34impl<T> Picker<T> {
35impl<T> Picker<T> {
35 pub fn new(
36 pub fn new(
36 options: Vec<T>,
37 options: Vec<T>,
37 format_fn: impl Fn(&T) -> Cow<str> + 'static,
38 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,
39 ) -> Self {
40 ) -> Self {
40 let prompt = Prompt::new(
41 let prompt = Prompt::new(
41 "".to_string(),
42 "".to_string(),
@@ -133,13 +134,6 @@ impl<T> Component for Picker<T> {
135 match key_event {
136 match key_event {
137− // code: KeyCode::Char(c),
138− // modifiers: KeyModifiers::NONE,
140− // self.insert_char(c);
141− // (self.callback_fn)(cx.editor, &self.line, PromptEvent::Update);
143 KeyEvent {
137 KeyEvent {
144 code: KeyCode::Up, ..
138 code: KeyCode::Up, ..
@@ -165,7 +159,25 @@ impl<T> Component for Picker<T> {
167 if let Some(option) = self.selection() {
161 if let Some(option) = self.selection() {
168− (self.callback_fn)(&mut cx.editor, option);
162+ (self.callback_fn)(&mut cx.editor, option, Action::Replace);
167+ code: KeyCode::Char('x'),
168+ modifiers: KeyModifiers::CONTROL,
170+ if let Some(option) = self.selection() {
171+ (self.callback_fn)(&mut cx.editor, option, Action::VerticalSplit);
176+ code: KeyCode::Char('v'),
177+ modifiers: KeyModifiers::CONTROL,
179+ if let Some(option) = self.selection() {
180+ (self.callback_fn)(&mut cx.editor, option, Action::HorizontalSplit);
170 return close_fn;
182 return close_fn;