Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

image_viewer: Fix image view tab icon lost (#17063)

CharlesChen0823804d1997f247
diff --git a/crates/image_viewer/Cargo.toml b/crates/image_viewer/Cargo.toml
index 70fe1426e2d..a3d454b0813 100644
--- a/crates/image_viewer/Cargo.toml
+++ b/crates/image_viewer/Cargo.toml
@@ -16,6 +16,8 @@ doctest = false
anyhow.workspace = true
db.workspace = true
gpui.workspace = true
+file_icons.workspace = true
ui.workspace = true
+settings.workspace = true
workspace.workspace = true
project.workspace = true
diff --git a/crates/image_viewer/src/image_viewer.rs b/crates/image_viewer/src/image_viewer.rs
index b43dabf55f3..5435d19000f 100644
--- a/crates/image_viewer/src/image_viewer.rs
+++ b/crates/image_viewer/src/image_viewer.rs
@@ -7,11 +7,13 @@ use gpui::{
use persistence::IMAGE_VIEWER;
use ui::prelude::*;
+use file_icons::FileIcons;
use project::{Project, ProjectEntryId, ProjectPath};
+use settings::Settings;
use std::{ffi::OsStr, path::PathBuf};
use workspace::{
item::{Item, ProjectItem, SerializableItem, TabContentParams},
- ItemId, Pane, Workspace, WorkspaceId,
+ ItemId, ItemSettings, Pane, Workspace, WorkspaceId,
};
const IMAGE_VIEWER_KIND: &str = "ImageView";
@@ -85,6 +87,14 @@ impl Item for ImageView {
.into_any_element()
}
+ fn tab_icon(&self, cx: &WindowContext) -> Option<Icon> {
+ ItemSettings::get_global(cx)
+ .file_icons
+ .then(|| FileIcons::get_icon(self.path.as_path(), cx))
+ .flatten()
+ .map(|icon| Icon::from_path(icon))
+ }
+
fn clone_on_split(
&self,
_workspace_id: Option<WorkspaceId>,