diff --git a/Cargo.lock b/Cargo.lock index 3804dce05aae8..73644261c3fc6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6171,6 +6171,7 @@ version = "0.1.0" dependencies = [ "anyhow", "db", + "editor", "file_icons", "gpui", "project", diff --git a/crates/image_viewer/Cargo.toml b/crates/image_viewer/Cargo.toml index 9c431e5edc6ec..f194b2c49565a 100644 --- a/crates/image_viewer/Cargo.toml +++ b/crates/image_viewer/Cargo.toml @@ -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 diff --git a/crates/image_viewer/src/image_viewer.rs b/crates/image_viewer/src/image_viewer.rs index c3f264d863b63..b5cd7eb6846dc 100644 --- a/crates/image_viewer/src/image_viewer.rs +++ b/crates/image_viewer/src/image_viewer.rs @@ -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() }