Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
branches: Add a modal branch list.
Piotr Osiewicze00e73f60848
diff --git a/Cargo.lock b/Cargo.lockindex 60ed830683a..ba24a756d14 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1491,6 +1491,7 @@ dependencies = ["theme","theme_selector","util",+ "vcs_menu","workspace","zed-actions",]@@ -8377,6 +8378,19 @@ version = "0.2.15"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"+[[package]]+name = "vcs_menu"+version = "0.1.0"+dependencies = [+ "anyhow",+ "fuzzy",+ "gpui",+ "picker",+ "theme",+ "util",+ "workspace",+]+[[package]]name = "version_check"version = "0.9.4"diff --git a/Cargo.toml b/Cargo.tomlindex 1708ccfc0a8..57578719621 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -64,6 +64,7 @@ members = ["crates/theme_selector","crates/util","crates/vim",+ "crates/vcs_menu","crates/workspace","crates/welcome","crates/xtask",diff --git a/assets/keymaps/default.json b/assets/keymaps/default.jsonindex 6fc06198fe8..8c3a1f407cb 100644--- a/assets/keymaps/default.json+++ b/assets/keymaps/default.json@@ -39,6 +39,7 @@"cmd-shift-n": "workspace::NewWindow","cmd-o": "workspace::Open","alt-cmd-o": "projects::OpenRecent",+ "alt-cmd-b": "branches::OpenRecent","ctrl-~": "workspace::NewTerminal","ctrl-`": "terminal_panel::ToggleFocus","shift-escape": "workspace::ToggleZoom"diff --git a/assets/keymaps/textmate.json b/assets/keymaps/textmate.jsonindex 591d6e443fe..1f28c05158a 100644--- a/assets/keymaps/textmate.json+++ b/assets/keymaps/textmate.json@@ -2,6 +2,7 @@{"bindings": {"cmd-shift-o": "projects::OpenRecent",+ "cmd-shift-b": "branches::OpenRecent","cmd-alt-tab": "project_panel::ToggleFocus"}},diff --git a/crates/collab_ui/Cargo.toml b/crates/collab_ui/Cargo.tomlindex f81885c07a0..4a38c2691cc 100644--- a/crates/collab_ui/Cargo.toml+++ b/crates/collab_ui/Cargo.toml@@ -39,6 +39,7 @@ recent_projects = {path = "../recent_projects"}settings = { path = "../settings" }theme = { path = "../theme" }theme_selector = { path = "../theme_selector" }+vcs_menu = { path = "../vcs_menu" }util = { path = "../util" }workspace = { path = "../workspace" }zed-actions = {path = "../zed-actions"}diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rsindex 57e3ea711d3..6cfc9d8e30e 100644--- a/crates/collab_ui/src/collab_titlebar_item.rs+++ b/crates/collab_ui/src/collab_titlebar_item.rs@@ -1,8 +1,5 @@use crate::{- branch_list::{build_branch_list, BranchList},- contact_notification::ContactNotification,- contacts_popover,- face_pile::FacePile,+ contact_notification::ContactNotification, contacts_popover, face_pile::FacePile,toggle_deafen, toggle_mute, toggle_screen_sharing, LeaveCall, ToggleDeafen, ToggleMute,ToggleScreenSharing,};@@ -27,6 +24,7 @@ use recent_projects::{build_recent_projects, RecentProjects};use std::{ops::Range, sync::Arc};use theme::{AvatarStyle, Theme};use util::ResultExt;+use vcs_menu::{build_branch_list, BranchList, OpenRecent as ToggleVcsMenu};use workspace::{FollowNextCollaborator, Workspace, WORKSPACE_DB};const MAX_PROJECT_NAME_LENGTH: usize = 40;@@ -37,7 +35,6 @@ actions!([ToggleContactsMenu,ToggleUserMenu,- ToggleVcsMenu,ToggleProjectMenu,SwitchBranch,ShareProject,@@ -286,7 +283,7 @@ impl CollabTitlebarItem {.with_tooltip::<BranchPopoverTooltip>(0,"Recent branches".into(),- None,+ Some(Box::new(ToggleVcsMenu)),theme.tooltip.clone(),cx,)diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rsindex 26d9c70a437..76f2e265711 100644--- a/crates/collab_ui/src/collab_ui.rs+++ b/crates/collab_ui/src/collab_ui.rs@@ -1,4 +1,3 @@-mod branch_list;mod collab_titlebar_item;mod contact_finder;mod contact_list;@@ -29,7 +28,7 @@ actions!();pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {- branch_list::init(cx);+ vcs_menu::init(cx);collab_titlebar_item::init(cx);contact_list::init(cx);contact_finder::init(cx);diff --git a/crates/vcs_menu/Cargo.toml b/crates/vcs_menu/Cargo.tomlnew file mode 100644index 00000000000..4ddf1214d0d--- /dev/null+++ b/crates/vcs_menu/Cargo.toml@@ -0,0 +1,16 @@+[package]+name = "vcs_menu"+version = "0.1.0"+edition = "2021"+publish = false+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html++[dependencies]+fuzzy = {path = "../fuzzy"}+gpui = {path = "../gpui"}+picker = {path = "../picker"}+util = {path = "../util"}+theme = {path = "../theme"}+workspace = {path = "../workspace"}++anyhow.workspace = truediff --git a/crates/collab_ui/src/branch_list.rs b/crates/vcs_menu/src/lib.rssimilarity index 89%rename from crates/collab_ui/src/branch_list.rsrename to crates/vcs_menu/src/lib.rsindex 16fefbd2ebc..b5b1036b36c 100644--- a/crates/collab_ui/src/branch_list.rs+++ b/crates/vcs_menu/src/lib.rs@@ -1,15 +1,17 @@-use anyhow::{anyhow, bail};+use anyhow::{anyhow, bail, Result};use fuzzy::{StringMatch, StringMatchCandidate};-use gpui::{elements::*, AppContext, MouseState, Task, ViewContext, ViewHandle};+use gpui::{actions, elements::*, AppContext, MouseState, Task, ViewContext, ViewHandle};use picker::{Picker, PickerDelegate, PickerEvent};use std::{ops::Not, sync::Arc};use util::ResultExt;use workspace::{Toast, Workspace};+actions!(branches, [OpenRecent]);+pub fn init(cx: &mut AppContext) {Picker::<BranchListDelegate>::init(cx);+ cx.add_async_action(toggle);}-pub type BranchList = Picker<BranchListDelegate>;pub fn build_branch_list(@@ -28,6 +30,34 @@ pub fn build_branch_list(.with_theme(|theme| theme.picker.clone())}+fn toggle(+ _: &mut Workspace,+ _: &OpenRecent,+ cx: &mut ViewContext<Workspace>,+) -> Option<Task<Result<()>>> {+ Some(cx.spawn(|workspace, mut cx| async move {+ workspace.update(&mut cx, |workspace, cx| {+ workspace.toggle_modal(cx, |_, cx| {+ let workspace = cx.handle();+ cx.add_view(|cx| {+ Picker::new(+ BranchListDelegate {+ matches: vec![],+ workspace,+ selected_index: 0,+ last_query: String::default(),+ },+ cx,+ )+ .with_theme(|theme| theme.picker.clone())+ .with_max_size(800., 1200.)+ })+ });+ })?;+ Ok(())+ }))+}+pub struct BranchListDelegate {matches: Vec<StringMatch>,workspace: ViewHandle<Workspace>,