aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/mod.rs
diff options
context:
space:
mode:
authorMichael Davis2023-06-18 17:23:15 +0000
committerMichael Davis2023-06-18 17:28:16 +0000
commit545acfda8884c890b78e586c86e4f7c5f9a15477 (patch)
treea2ff7204be3cda93bd558aedc0022b2b99e6e707 /helix-term/src/ui/mod.rs
parentfc111213b5b5a3130399cda8a1964fa89acf153a (diff)
Make file preview callback optional
When Picker and FilePicker are merged, not all Pickers will be able to show a preview. Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
Diffstat (limited to 'helix-term/src/ui/mod.rs')
-rw-r--r--helix-term/src/ui/mod.rs26
1 files changed, 11 insertions, 15 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index ec328ec5..c5e66d86 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -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)),
- )
+ 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);
+ }
+ })
+ .with_preview(|_editor, path| Some((path.clone().into(), None)))
}
pub mod completers {