Cargo.lock 🔗
@@ -6171,6 +6171,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"db",
+ "editor",
"file_icons",
"gpui",
"project",
Nils Koch created
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
Cargo.lock | 1 +
crates/image_viewer/Cargo.toml | 1 +
crates/image_viewer/src/image_viewer.rs | 22 ++++++++++++++++++----
3 files changed, 20 insertions(+), 4 deletions(-)
@@ -6171,6 +6171,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"db",
+ "editor",
"file_icons",
"gpui",
"project",
@@ -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()
}