From 59d61d33cbd70821174f340124d9992489f935b4 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 12 Jul 2021 17:44:53 +0200 Subject: [PATCH] Allow worktrees to be joined with no open window Co-Authored-By: Nathan Sobo --- zed/src/workspace.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/zed/src/workspace.rs b/zed/src/workspace.rs index 8541fb2377ecf5e0bfc51667e4f24ebb4aac03fb..0de8d3e5bf7ddb7d6954466f439e3e021458443c 100644 --- a/zed/src/workspace.rs +++ b/zed/src/workspace.rs @@ -31,6 +31,7 @@ pub fn init(cx: &mut MutableAppContext) { cx.add_global_action("workspace:open", open); cx.add_global_action("workspace:open_paths", open_paths); cx.add_global_action("workspace:new_file", open_new); + cx.add_global_action("workspace:join_worktree", join_worktree); cx.add_action("workspace:save", Workspace::save_active_item); cx.add_action("workspace:debug_elements", Workspace::debug_elements); cx.add_action("workspace:new_file", Workspace::open_new_file); @@ -114,6 +115,19 @@ fn open_new(app_state: &Arc, cx: &mut MutableAppContext) { }); } +fn join_worktree(app_state: &Arc, cx: &mut MutableAppContext) { + cx.add_window(|cx| { + let mut view = Workspace::new( + app_state.settings.clone(), + app_state.languages.clone(), + app_state.rpc.clone(), + cx, + ); + view.join_worktree(&app_state, cx); + view + }); +} + pub trait Item: Entity + Sized { type View: ItemView;