Return back git status colors for tab labels
This commit is contained in:
parent
fbf2f790dd
commit
3070a6ef26
3 changed files with 36 additions and 11 deletions
|
@ -15,9 +15,11 @@ use language::{
|
||||||
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, CharKind, OffsetRangeExt,
|
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, CharKind, OffsetRangeExt,
|
||||||
Point, SelectionGoal,
|
Point, SelectionGoal,
|
||||||
};
|
};
|
||||||
|
use project::repository::GitFileStatus;
|
||||||
use project::{search::SearchQuery, FormatTrigger, Item as _, Project, ProjectPath};
|
use project::{search::SearchQuery, FormatTrigger, Item as _, Project, ProjectPath};
|
||||||
use rpc::proto::{self, update_view, PeerId};
|
use rpc::proto::{self, update_view, PeerId};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
use workspace::item::ItemSettings;
|
||||||
|
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -29,7 +31,7 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use text::Selection;
|
use text::Selection;
|
||||||
use theme::{ActiveTheme, Theme};
|
use theme::Theme;
|
||||||
use ui::{h_stack, prelude::*, Label};
|
use ui::{h_stack, prelude::*, Label};
|
||||||
use util::{paths::PathExt, paths::FILE_ROW_COLUMN_DELIMITER, ResultExt, TryFutureExt};
|
use util::{paths::PathExt, paths::FILE_ROW_COLUMN_DELIMITER, ResultExt, TryFutureExt};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
|
@ -579,7 +581,28 @@ impl Item for Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tab_content(&self, detail: Option<usize>, selected: bool, cx: &WindowContext) -> AnyElement {
|
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 description = detail.and_then(|detail| {
|
||||||
let path = path_for_buffer(&self.buffer, detail, false, cx)?;
|
let path = path_for_buffer(&self.buffer, detail, false, cx)?;
|
||||||
|
@ -595,11 +618,7 @@ impl Item for Editor {
|
||||||
|
|
||||||
h_stack()
|
h_stack()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.child(Label::new(self.title(cx).to_string()).color(if selected {
|
.child(Label::new(self.title(cx).to_string()).color(label_color))
|
||||||
Color::Default
|
|
||||||
} else {
|
|
||||||
Color::Muted
|
|
||||||
}))
|
|
||||||
.when_some(description, |this, description| {
|
.when_some(description, |this, description| {
|
||||||
this.child(
|
this.child(
|
||||||
Label::new(description)
|
Label::new(description)
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use crate::{private::Sealed, AppContext, Context, Entity, ModelContext};
|
use crate::{private::Sealed, AppContext, Context, Entity, ModelContext};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use collections::HashMap;
|
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
|
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
|
||||||
use slotmap::{SecondaryMap, SlotMap};
|
use slotmap::{SecondaryMap, SlotMap};
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -18,6 +16,9 @@ use std::{
|
||||||
thread::panicking,
|
thread::panicking,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
use collections::HashMap;
|
||||||
|
|
||||||
slotmap::new_key_type! { pub struct EntityId; }
|
slotmap::new_key_type! { pub struct EntityId; }
|
||||||
|
|
||||||
impl EntityId {
|
impl EntityId {
|
||||||
|
@ -600,7 +601,7 @@ impl<T> PartialEq<Model<T>> for WeakModel<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref LEAK_BACKTRACE: bool =
|
static ref LEAK_BACKTRACE: bool =
|
||||||
std::env::var("LEAK_BACKTRACE").map_or(false, |b| !b.is_empty());
|
std::env::var("LEAK_BACKTRACE").map_or(false, |b| !b.is_empty());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1128,7 +1128,12 @@ impl Pane {
|
||||||
if self.items.len() == 1 && should_activate {
|
if self.items.len() == 1 && should_activate {
|
||||||
self.focus_handle.focus(cx);
|
self.focus_handle.focus(cx);
|
||||||
} else {
|
} 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,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue