Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Restore welcome page and several pickers
Mikaylaed8e62cd18c4
diff --git a/crates/project_panel2/src/file_associations.rs b/crates/project_panel2/src/file_associations.rsindex 9e9a865f3e7..82aebe79131 100644--- a/crates/project_panel2/src/file_associations.rs+++ b/crates/project_panel2/src/file_associations.rs@@ -41,56 +41,47 @@ impl FileAssociations {})}- pub fn get_icon(path: &Path, cx: &AppContext) -> Arc<str> {- maybe!({- let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;+ pub fn get_icon(path: &Path, cx: &AppContext) -> Option<Arc<str>> {+ let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;- // FIXME: Associate a type with the languages and have the file's langauge- // override these associations- maybe!({- let suffix = path.icon_suffix()?;+ // FIXME: Associate a type with the languages and have the file's langauge+ // override these associations+ maybe!({+ let suffix = path.icon_suffix()?;- this.suffixes- .get(suffix)- .and_then(|type_str| this.types.get(type_str))- .map(|type_config| type_config.icon.clone())- })- .or_else(|| this.types.get("default").map(|config| config.icon.clone()))+ this.suffixes+ .get(suffix)+ .and_then(|type_str| this.types.get(type_str))+ .map(|type_config| type_config.icon.clone())})- .unwrap_or_else(|| Arc::from("".to_string()))+ .or_else(|| this.types.get("default").map(|config| config.icon.clone()))}- pub fn get_folder_icon(expanded: bool, cx: &AppContext) -> Arc<str> {- maybe!({- let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;+ pub fn get_folder_icon(expanded: bool, cx: &AppContext) -> Option<Arc<str>> {+ let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;- let key = if expanded {- EXPANDED_DIRECTORY_TYPE- } else {- COLLAPSED_DIRECTORY_TYPE- };+ let key = if expanded {+ EXPANDED_DIRECTORY_TYPE+ } else {+ COLLAPSED_DIRECTORY_TYPE+ };- this.types- .get(key)- .map(|type_config| type_config.icon.clone())- })- .unwrap_or_else(|| Arc::from("".to_string()))+ this.types+ .get(key)+ .map(|type_config| type_config.icon.clone())}- pub fn get_chevron_icon(expanded: bool, cx: &AppContext) -> Arc<str> {- maybe!({- let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;+ pub fn get_chevron_icon(expanded: bool, cx: &AppContext) -> Option<Arc<str>> {+ let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;- let key = if expanded {- EXPANDED_CHEVRON_TYPE- } else {- COLLAPSED_CHEVRON_TYPE- };+ let key = if expanded {+ EXPANDED_CHEVRON_TYPE+ } else {+ COLLAPSED_CHEVRON_TYPE+ };- this.types- .get(key)- .map(|type_config| type_config.icon.clone())- })- .unwrap_or_else(|| Arc::from("".to_string()))+ this.types+ .get(key)+ .map(|type_config| type_config.icon.clone())}}diff --git a/crates/project_panel2/src/project_panel.rs b/crates/project_panel2/src/project_panel.rsindex b0272098702..c1f30d029f0 100644--- a/crates/project_panel2/src/project_panel.rs+++ b/crates/project_panel2/src/project_panel.rs@@ -1269,16 +1269,16 @@ impl ProjectPanel {let icon = match entry.kind {EntryKind::File(_) => {if show_file_icons {- Some(FileAssociations::get_icon(&entry.path, cx))+ FileAssociations::get_icon(&entry.path, cx)} else {None}}_ => {if show_folder_icons {- Some(FileAssociations::get_folder_icon(is_expanded, cx))+ FileAssociations::get_folder_icon(is_expanded, cx)} else {- Some(FileAssociations::get_chevron_icon(is_expanded, cx))+ FileAssociations::get_chevron_icon(is_expanded, cx)}}};diff --git a/crates/welcome2/src/welcome.rs b/crates/welcome2/src/welcome.rsindex 68b515f577e..441c2bf6966 100644--- a/crates/welcome2/src/welcome.rs+++ b/crates/welcome2/src/welcome.rs@@ -58,6 +58,7 @@ impl Render for WelcomePage {type Element = Focusable<Div>;fn render(&mut self, _cx: &mut gpui::ViewContext<Self>) -> Self::Element {+ // todo!(welcome_ui)// let self_handle = cx.handle();// let theme = cx.theme();// let width = theme.welcome.page_width;diff --git a/crates/zed2/src/main.rs b/crates/zed2/src/main.rsindex 4d9a61a52f8..0c65d115d3b 100644--- a/crates/zed2/src/main.rs+++ b/crates/zed2/src/main.rs@@ -166,7 +166,7 @@ fn main() {// cx.spawn(|_| watch_languages(fs.clone(), languages.clone()))// .detach();- // watch_file_types(fs.clone(), cx);+ watch_file_types(fs.clone(), cx);languages.set_theme(cx.theme().clone());cx.observe_global::<SettingsStore>({@@ -722,31 +722,33 @@ async fn watch_languages(fs: Arc<dyn fs::Fs>, languages: Arc<LanguageRegistry>)Some(())}-//todo!()-// #[cfg(debug_assertions)]-// fn watch_file_types(fs: Arc<dyn Fs>, cx: &mut AppContext) {-// cx.spawn(|mut cx| async move {-// let mut events = fs-// .watch(-// "assets/icons/file_icons/file_types.json".as_ref(),-// Duration::from_millis(100),-// )-// .await;-// while (events.next().await).is_some() {-// cx.update(|cx| {-// cx.update_global(|file_types, _| {-// *file_types = project_panel::file_associations::FileAssociations::new(Assets);-// });-// })-// }-// })-// .detach()-// }+#[cfg(debug_assertions)]+fn watch_file_types(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {+ use std::time::Duration;++ cx.spawn(|mut cx| async move {+ let mut events = fs+ .watch(+ "assets/icons/file_icons/file_types.json".as_ref(),+ Duration::from_millis(100),+ )+ .await;+ while (events.next().await).is_some() {+ cx.update(|cx| {+ cx.update_global(|file_types, _| {+ *file_types = project_panel::file_associations::FileAssociations::new(Assets);+ });+ })+ .ok();+ }+ })+ .detach()+}#[cfg(not(debug_assertions))]async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()> {None}-// #[cfg(not(debug_assertions))]-// fn watch_file_types(_fs: Arc<dyn Fs>, _cx: &mut AppContext) {}+#[cfg(not(debug_assertions))]+fn watch_file_types(_fs: Arc<dyn Fs>, _cx: &mut AppContext) {}