diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 231372a1a..9bd1a561e 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -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))); } diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 49a3d87ac..c9814ca46 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -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 {