|
|
@ -266,8 +266,8 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
|
|
|
|
picker
|
|
|
|
picker
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn file_browser(root: PathBuf) -> FilePicker {
|
|
|
|
pub fn file_browser(root: PathBuf) -> Result<FilePicker, std::io::Error> {
|
|
|
|
let directory_content = directory_content(&root);
|
|
|
|
let directory_content = directory_content(&root)?;
|
|
|
|
|
|
|
|
|
|
|
|
let columns = [PickerColumn::new(
|
|
|
|
let columns = [PickerColumn::new(
|
|
|
|
"path",
|
|
|
|
"path",
|
|
|
@ -278,38 +278,37 @@ pub fn file_browser(root: PathBuf) -> FilePicker {
|
|
|
|
.into()
|
|
|
|
.into()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)];
|
|
|
|
)];
|
|
|
|
let picker = Picker::new(columns, 0, [], root, move |cx, path: &PathBuf, action| {
|
|
|
|
let picker = Picker::new(
|
|
|
|
if path.is_dir() {
|
|
|
|
columns,
|
|
|
|
let owned_path = path.clone();
|
|
|
|
0,
|
|
|
|
let callback = Box::pin(async move {
|
|
|
|
directory_content,
|
|
|
|
let call: Callback =
|
|
|
|
root,
|
|
|
|
Callback::EditorCompositor(Box::new(move |_editor, compositor| {
|
|
|
|
move |cx, path: &PathBuf, action| {
|
|
|
|
let picker = file_browser(owned_path);
|
|
|
|
if path.is_dir() {
|
|
|
|
compositor.push(Box::new(overlay::overlaid(picker)));
|
|
|
|
let owned_path = path.clone();
|
|
|
|
}));
|
|
|
|
let callback = Box::pin(async move {
|
|
|
|
Ok(call)
|
|
|
|
let call: Callback =
|
|
|
|
});
|
|
|
|
Callback::EditorCompositor(Box::new(move |_editor, compositor| {
|
|
|
|
cx.jobs.callback(callback);
|
|
|
|
if let Ok(picker) = file_browser(owned_path) {
|
|
|
|
} else if let Err(e) = cx.editor.open(path, action) {
|
|
|
|
compositor.push(Box::new(overlay::overlaid(picker)));
|
|
|
|
let err = if let Some(err) = e.source() {
|
|
|
|
}
|
|
|
|
format!("{}", err)
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
Ok(call)
|
|
|
|
format!("unable to open \"{}\"", path.display())
|
|
|
|
});
|
|
|
|
};
|
|
|
|
cx.jobs.callback(callback);
|
|
|
|
cx.editor.set_error(err);
|
|
|
|
} else 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.as_path().into(), None)));
|
|
|
|
.with_preview(|_editor, path| Some((path.as_path().into(), None)));
|
|
|
|
let injector = picker.injector();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let Ok(files) = directory_content {
|
|
|
|
Ok(picker)
|
|
|
|
for file in files {
|
|
|
|
|
|
|
|
if injector.push(file).is_err() {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
picker
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn directory_content(path: &Path) -> Result<Vec<PathBuf>, std::io::Error> {
|
|
|
|
fn directory_content(path: &Path) -> Result<Vec<PathBuf>, std::io::Error> {
|
|
|
|