Fix git colors in image tabs (#21773)
Note that the git coloring of the icons got removed in https://github.com/zed-industries/zed/pull/21383 Closes #21772 Release Notes: - N/A
This commit is contained in:
parent
44164dbbb8
commit
bd2087675b
3 changed files with 20 additions and 4 deletions
|
@ -15,6 +15,7 @@ doctest = false
|
|||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
db.workspace = true
|
||||
editor.workspace = true
|
||||
file_icons.workspace = true
|
||||
gpui.workspace = true
|
||||
project.workspace = true
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use anyhow::Context as _;
|
||||
use editor::items::entry_git_aware_label_color;
|
||||
use gpui::{
|
||||
canvas, div, fill, img, opaque_grey, point, size, AnyElement, AppContext, Bounds, EventEmitter,
|
||||
FocusHandle, FocusableView, InteractiveElement, IntoElement, Model, ObjectFit, ParentElement,
|
||||
|
@ -94,15 +95,28 @@ impl Item for ImageView {
|
|||
}
|
||||
|
||||
fn tab_content(&self, params: TabContentParams, cx: &WindowContext) -> AnyElement {
|
||||
let path = self.image_item.read(cx).file.path();
|
||||
let title = path
|
||||
let project_path = self.image_item.read(cx).project_path(cx);
|
||||
let label_color = if ItemSettings::get_global(cx).git_status {
|
||||
self.project
|
||||
.read(cx)
|
||||
.entry_for_path(&project_path, cx)
|
||||
.map(|entry| {
|
||||
entry_git_aware_label_color(entry.git_status, entry.is_ignored, params.selected)
|
||||
})
|
||||
.unwrap_or_else(|| params.text_color())
|
||||
} else {
|
||||
params.text_color()
|
||||
};
|
||||
|
||||
let title = project_path
|
||||
.path
|
||||
.file_name()
|
||||
.unwrap_or_else(|| path.as_os_str())
|
||||
.unwrap_or_else(|| project_path.path.as_os_str())
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
Label::new(title)
|
||||
.single_line()
|
||||
.color(params.text_color())
|
||||
.color(label_color)
|
||||
.italic(params.preview)
|
||||
.into_any_element()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue