Allow worktrees to be joined with no open window

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2021-07-12 17:44:53 +02:00
parent 58bae3a9a7
commit 59d61d33cb

View file

@ -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<AppState>, cx: &mut MutableAppContext) {
});
}
fn join_worktree(app_state: &Arc<AppState>, 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;