diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index b18acee233..d5ec34ad69 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -77,6 +77,7 @@ actions!( Open, NewFile, NewWindow, + AddFolderToProject, Unfollow, Save, ActivatePreviousPane, @@ -140,6 +141,7 @@ pub fn init(app_state: Arc, cx: &mut MutableAppContext) { cx.add_async_action(Workspace::toggle_follow); cx.add_async_action(Workspace::follow_next_collaborator); + cx.add_action(Workspace::add_folder_to_project); cx.add_action( |workspace: &mut Workspace, _: &Unfollow, cx: &mut ViewContext| { let pane = workspace.active_pane().clone(); @@ -921,6 +923,27 @@ impl Workspace { }) } + fn add_folder_to_project(&mut self, _: &AddFolderToProject, cx: &mut ViewContext) { + let mut paths = cx.prompt_for_paths(PathPromptOptions { + files: false, + directories: true, + multiple: true, + }); + cx.spawn(|this, mut cx| async move { + if let Some(paths) = paths.recv().await.flatten() { + let results = this + .update(&mut cx, |this, cx| this.open_paths(paths, cx)) + .await; + for result in results { + if let Some(result) = result { + result.log_err(); + } + } + } + }) + .detach(); + } + fn project_path_for_path( &self, abs_path: &Path, diff --git a/crates/zed/src/menus.rs b/crates/zed/src/menus.rs index 45104399c5..6267ac77c9 100644 --- a/crates/zed/src/menus.rs +++ b/crates/zed/src/menus.rs @@ -42,6 +42,10 @@ pub fn menus() -> Vec> { name: "Open…", action: Box::new(workspace::Open), }, + MenuItem::Action { + name: "Add Folder to Project…", + action: Box::new(workspace::AddFolderToProject), + }, MenuItem::Action { name: "Save", action: Box::new(workspace::Save),