diff --git a/crates/file_icons/src/file_icons.rs b/crates/file_icons/src/file_icons.rs index ff653e6693..056a39a658 100644 --- a/crates/file_icons/src/file_icons.rs +++ b/crates/file_icons/src/file_icons.rs @@ -1,14 +1,14 @@ -use std::{path::Path, str, sync::Arc}; +use std::{path::Path, str}; use collections::HashMap; -use gpui::{AppContext, AssetSource, Global}; +use gpui::{AppContext, AssetSource, Global, SharedString}; use serde_derive::Deserialize; use util::{maybe, paths::PathExt}; #[derive(Deserialize, Debug)] struct TypeConfig { - icon: Arc, + icon: SharedString, } #[derive(Deserialize, Debug)] @@ -48,7 +48,7 @@ impl FileIcons { }) } - pub fn get_icon(path: &Path, cx: &AppContext) -> Option> { + pub fn get_icon(path: &Path, cx: &AppContext) -> Option { let this = cx.try_global::()?; // FIXME: Associate a type with the languages and have the file's language @@ -67,13 +67,13 @@ impl FileIcons { .or_else(|| this.get_type_icon("default")) } - pub fn get_type_icon(&self, typ: &str) -> Option> { + pub fn get_type_icon(&self, typ: &str) -> Option { self.types .get(typ) .map(|type_config| type_config.icon.clone()) } - pub fn get_folder_icon(expanded: bool, cx: &AppContext) -> Option> { + pub fn get_folder_icon(expanded: bool, cx: &AppContext) -> Option { let this = cx.try_global::()?; let key = if expanded { @@ -85,7 +85,7 @@ impl FileIcons { this.get_type_icon(key) } - pub fn get_chevron_icon(expanded: bool, cx: &AppContext) -> Option> { + pub fn get_chevron_icon(expanded: bool, cx: &AppContext) -> Option { let this = cx.try_global::()?; let key = if expanded { diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index c2f26d2e5c..2515e77069 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -94,7 +94,7 @@ enum ClipboardEntry { #[derive(Debug, PartialEq, Eq, Clone)] pub struct EntryDetails { filename: String, - icon: Option>, + icon: Option, path: Arc, depth: usize, kind: EntryKind, @@ -108,7 +108,7 @@ pub struct EntryDetails { git_status: Option, is_private: bool, worktree_id: WorktreeId, - canonical_path: Option, + canonical_path: Option>, } #[derive(PartialEq, Clone, Default, Debug, Deserialize)] @@ -2538,7 +2538,7 @@ impl Render for DraggedProjectEntryView { .indent_level(self.details.depth) .indent_step_size(px(settings.indent_size)) .child(if let Some(icon) = &self.details.icon { - div().child(Icon::from_path(icon.to_string())) + div().child(Icon::from_path(icon.clone())) } else { div() }) diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 19c91d9595..4d60572cf7 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -3127,7 +3127,7 @@ pub struct Entry { pub inode: u64, pub mtime: Option, - pub canonical_path: Option, + pub canonical_path: Option>, pub is_symlink: bool, /// Whether this entry is ignored by Git. /// @@ -3186,7 +3186,7 @@ impl Entry { metadata: &fs::Metadata, next_entry_id: &AtomicUsize, root_char_bag: CharBag, - canonical_path: Option, + canonical_path: Option>, ) -> Self { Self { id: ProjectEntryId::new(next_entry_id), @@ -3942,7 +3942,7 @@ impl BackgroundScanner { child_entry.is_external = true; } - child_entry.canonical_path = Some(canonical_path); + child_entry.canonical_path = Some(canonical_path.into()); } if child_entry.is_dir() { @@ -4073,21 +4073,21 @@ impl BackgroundScanner { } } - for (path, metadata) in relative_paths.iter().zip(metadata.iter()) { + for (path, metadata) in relative_paths.iter().zip(metadata.into_iter()) { let abs_path: Arc = root_abs_path.join(&path).into(); match metadata { Ok(Some((metadata, canonical_path))) => { let ignore_stack = state .snapshot .ignore_stack_for_abs_path(&abs_path, metadata.is_dir); - + let is_external = !canonical_path.starts_with(&root_canonical_path); let mut fs_entry = Entry::new( path.clone(), - metadata, + &metadata, self.next_entry_id.as_ref(), state.snapshot.root_char_bag, if metadata.is_symlink { - Some(canonical_path.to_path_buf()) + Some(canonical_path.into()) } else { None }, @@ -4096,7 +4096,7 @@ impl BackgroundScanner { let is_dir = fs_entry.is_dir(); fs_entry.is_ignored = ignore_stack.is_abs_path_ignored(&abs_path, is_dir); - fs_entry.is_external = !canonical_path.starts_with(&root_canonical_path); + fs_entry.is_external = is_external; fs_entry.is_private = self.is_path_private(path); if !is_dir && !fs_entry.is_ignored && !fs_entry.is_external {