diff options
author | Pascal Kuthe | 2023-06-19 02:18:42 +0000 |
---|---|---|
committer | GitHub | 2023-06-19 02:18:42 +0000 |
commit | 06d63d6ac1644ce57d6a90b53ea4f832e67ab2a9 (patch) | |
tree | af461a6c93f76be80370655c8bcc9fa2d2c0ecc5 /helix-term/src/ui/mod.rs | |
parent | 29638babea410d6d8397b02e6a826de0076a69c0 (diff) | |
parent | f18acadbd0d7b15bc314fc3ede99f4546b72d76d (diff) |
Merge pull request #7264 from the-mikedavis/merge-picker-and-filepicker
Merge FilePicker into Picker
Diffstat (limited to 'helix-term/src/ui/mod.rs')
-rw-r--r-- | helix-term/src/ui/mod.rs | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index ec328ec5..155f2435 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -21,7 +21,7 @@ pub use completion::{Completion, CompletionItem}; pub use editor::EditorView; pub use markdown::Markdown; pub use menu::Menu; -pub use picker::{DynamicPicker, FileLocation, FilePicker, Picker}; +pub use picker::{DynamicPicker, FileLocation, Picker}; pub use popup::Popup; pub use prompt::{Prompt, PromptEvent}; pub use spinner::{ProgressSpinners, Spinner}; @@ -158,7 +158,7 @@ pub fn regex_prompt( cx.push_layer(Box::new(prompt)); } -pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePicker<PathBuf> { +pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> Picker<PathBuf> { use ignore::{types::TypesBuilder, WalkBuilder}; use std::time::Instant; @@ -217,21 +217,17 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi log::debug!("file_picker init {:?}", Instant::now().duration_since(now)); - FilePicker::new( - files, - root, - move |cx, path: &PathBuf, action| { - if let Err(e) = cx.editor.open(path, action) { - let err = if let Some(err) = e.source() { - format!("{}", err) - } else { - format!("unable to open \"{}\"", path.display()) - }; - cx.editor.set_error(err); - } - }, - |_editor, path| Some((path.clone().into(), None)), - ) + Picker::new(files, root, move |cx, path: &PathBuf, action| { + if let Err(e) = cx.editor.open(path, action) { + let err = if let Some(err) = e.source() { + format!("{}", err) + } else { + format!("unable to open \"{}\"", path.display()) + }; + cx.editor.set_error(err); + } + }) + .with_preview(|_editor, path| Some((path.clone().into(), None))) } pub mod completers { |