Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add branch name into title
Mikayla Maki8f0aa3c6d95e
diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rsindex de9f9615d52..41d0315ee32 100644--- a/crates/collab_ui/src/collab_titlebar_item.rs+++ b/crates/collab_ui/src/collab_titlebar_item.rs@@ -178,7 +178,9 @@ impl CollabTitlebarItem {let branch = worktree.read(cx).snapshot()- .git_branch()+ .root_git_entry()+ .and_then(|entry| entry.branch())+ .map(|branch| branch.to_string()).unwrap_or_else(|| "".to_owned());format!("{} / {}", name, branch)}@@ -206,7 +208,7 @@ impl CollabTitlebarItem {Label::new(title.to_owned(), text_style).contained()- .with_margin_right(dbg!(item_spacing))+ .with_margin_right(item_spacing).aligned().left().into_any_named("title-with-git-information")diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rsindex 88886347bc1..fed98d49edc 100644--- a/crates/project/src/worktree.rs+++ b/crates/project/src/worktree.rs@@ -1484,10 +1484,6 @@ impl Snapshot {pub fn inode_for_path(&self, path: impl AsRef<Path>) -> Option<u64> {self.entry_for_path(path.as_ref()).map(|e| e.inode)}-- pub fn git_branch(&self) -> Option<String> {- Some("test".to_owned())- }}impl LocalSnapshot {@@ -1700,6 +1696,7 @@ impl LocalSnapshot {let key = RepositoryWorkDirectory(content_path.clone());if self.repository_entries.get(&key).is_none() {if let Some(repo) = fs.open_repo(abs_path.as_path()) {+ let repo_lock = repo.lock();self.repository_entries.insert(key.clone(),RepositoryEntry {@@ -1707,9 +1704,10 @@ impl LocalSnapshot {git_dir_entry_id: parent_entry.id,work_directory: key,scan_id: 0,- branch: None,+ branch: repo_lock.branch_name().map(Into::into),},);+ drop(repo_lock);self.git_repositories.insert(parent_entry.id, repo)}