Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Return back git status colors for tab labels
Kirill Bulatov3070a6ef2674
diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rsindex 31c4e24659f..9e198fa2fdc 100644--- a/crates/editor/src/items.rs+++ b/crates/editor/src/items.rs@@ -15,9 +15,11 @@ use language::{proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, CharKind, OffsetRangeExt,Point, SelectionGoal,};+use project::repository::GitFileStatus;use project::{search::SearchQuery, FormatTrigger, Item as _, Project, ProjectPath};use rpc::proto::{self, update_view, PeerId};use settings::Settings;+use workspace::item::ItemSettings;use std::fmt::Write;use std::{@@ -29,7 +31,7 @@ use std::{sync::Arc,};use text::Selection;-use theme::{ActiveTheme, Theme};+use theme::Theme;use ui::{h_stack, prelude::*, Label};use util::{paths::PathExt, paths::FILE_ROW_COLUMN_DELIMITER, ResultExt, TryFutureExt};use workspace::{@@ -579,7 +581,28 @@ impl Item for Editor {}fn tab_content(&self, detail: Option<usize>, selected: bool, cx: &WindowContext) -> AnyElement {- let _theme = cx.theme();+ let git_status = if ItemSettings::get_global(cx).git_status {+ self.buffer()+ .read(cx)+ .as_singleton()+ .and_then(|buffer| buffer.read(cx).project_path(cx))+ .and_then(|path| self.project.as_ref()?.read(cx).entry_for_path(&path, cx))+ .and_then(|entry| entry.git_status())+ } else {+ None+ };+ let label_color = match git_status {+ Some(GitFileStatus::Added) => Color::Created,+ Some(GitFileStatus::Modified) => Color::Modified,+ Some(GitFileStatus::Conflict) => Color::Conflict,+ None => {+ if selected {+ Color::Default+ } else {+ Color::Muted+ }+ }+ };let description = detail.and_then(|detail| {let path = path_for_buffer(&self.buffer, detail, false, cx)?;@@ -595,11 +618,7 @@ impl Item for Editor {h_stack().gap_2()- .child(Label::new(self.title(cx).to_string()).color(if selected {- Color::Default- } else {- Color::Muted- }))+ .child(Label::new(self.title(cx).to_string()).color(label_color)).when_some(description, |this, description| {this.child(Label::new(description)diff --git a/crates/gpui/src/app/entity_map.rs b/crates/gpui/src/app/entity_map.rsindex 3bab9d00f90..97f680560a3 100644--- a/crates/gpui/src/app/entity_map.rs+++ b/crates/gpui/src/app/entity_map.rs@@ -1,8 +1,6 @@use crate::{private::Sealed, AppContext, Context, Entity, ModelContext};use anyhow::{anyhow, Result};-use collections::HashMap;use derive_more::{Deref, DerefMut};-use lazy_static::lazy_static;use parking_lot::{RwLock, RwLockUpgradableReadGuard};use slotmap::{SecondaryMap, SlotMap};use std::{@@ -18,6 +16,9 @@ use std::{thread::panicking,};+#[cfg(any(test, feature = "test-support"))]+use collections::HashMap;+slotmap::new_key_type! { pub struct EntityId; }impl EntityId {@@ -600,7 +601,7 @@ impl<T> PartialEq<Model<T>> for WeakModel<T> {}#[cfg(any(test, feature = "test-support"))]-lazy_static! {+lazy_static::lazy_static! {static ref LEAK_BACKTRACE: bool =std::env::var("LEAK_BACKTRACE").map_or(false, |b| !b.is_empty());}diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rsindex 21c5962bebb..91e2890adb1 100644--- a/crates/workspace/src/pane.rs+++ b/crates/workspace/src/pane.rs@@ -1128,7 +1128,12 @@ impl Pane {if self.items.len() == 1 && should_activate {self.focus_handle.focus(cx);} else {- self.activate_item(index_to_activate, should_activate, should_activate, cx);+ self.activate_item(+ dbg!(index_to_activate),+ dbg!(should_activate),+ should_activate,+ cx,+ );}}