Implement opening of folders

pull/11285/head
Denys Rybalka 4 months ago
parent 7b0f7dbfbe
commit 084d1811ea
No known key found for this signature in database
GPG Key ID: 1F6284E97DB46ED1

@ -2956,7 +2956,7 @@ fn file_browser(cx: &mut Context) {
.set_error("Current working directory does not exist");
return;
}
let picker = ui::file_browser(cwd, &cx.editor.config());
let picker = ui::file_browser(cwd);
cx.push_layer(Box::new(overlaid(picker)));
}

@ -266,7 +266,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
picker
}
pub fn file_browser(root: PathBuf, _config: &helix_view::editor::Config) -> FilePicker {
pub fn file_browser(root: PathBuf) -> FilePicker {
let directory_content = directory_content(&root);
let columns = [PickerColumn::new(
@ -279,7 +279,18 @@ pub fn file_browser(root: PathBuf, _config: &helix_view::editor::Config) -> File
},
)];
let picker = Picker::new(columns, 0, [], root, move |cx, path: &PathBuf, action| {
if let Err(e) = cx.editor.open(path, action) {
if path.is_dir() {
let owned_path = path.clone();
let callback = Box::pin(async move {
let call: Callback =
Callback::EditorCompositor(Box::new(move |_editor, compositor| {
let picker = file_browser(owned_path);
compositor.push(Box::new(overlay::overlaid(picker)));
}));
Ok(call)
});
cx.jobs.callback(callback);
} else if let Err(e) = cx.editor.open(path, action) {
let err = if let Some(err) = e.source() {
format!("{}", err)
} else {

Loading…
Cancel
Save