@@ -65,12 +65,28 @@ fn open(cx: &mut compositor::Context, args: &[Cow<str>], event: PromptEvent) ->
6565 ensure!(!args.is_empty(), "wrong argument count");
6666 for arg in args {
6767 let (path, pos) = args::parse_file(arg);
68− let _ = cx.editor.open(&path, Action::Replace)?;
69− let (view, doc) = current!(cx.editor);
70− let pos = Selection::point(pos_at_coords(doc.text().slice(..), pos, true));
71− doc.set_selection(view.id, pos);
72− // does not affect opening a buffer without pos
73− align_view(doc, view, Align::Center);
68+ // If the path is a directory, open a file picker on that directory and update the status
69+ // message
70+ if std::fs::canonicalize(&path)?.is_dir() {
71+ let callback = async move {
72+ let call: job::Callback = job::Callback::EditorCompositor(Box::new(
73+ move |editor: &mut Editor, compositor: &mut Compositor| {
74+ let picker = ui::file_picker(path, &editor.config());
75+ compositor.push(Box::new(overlayed(picker)));
76+ },
77+ ));
78+ Ok(call)
79+ };
80+ cx.jobs.callback(callback);
81+ } else {
82+ // Otherwise, just open the file
83+ let _ = cx.editor.open(&path, Action::Replace)?;
84+ let (view, doc) = current!(cx.editor);
85+ let pos = Selection::point(pos_at_coords(doc.text().slice(..), pos, true));
86+ doc.set_selection(view.id, pos);
87+ // does not affect opening a buffer without pos
88+ align_view(doc, view, Align::Center);
89+ }
7490 }
7591 Ok(())
7692}