Use try_global()

This commit is contained in:
Joseph T. Lyons 2024-01-18 00:58:50 -05:00
parent 933fb87013
commit b807e6fe80
10 changed files with 52 additions and 70 deletions

View file

@ -42,7 +42,7 @@ impl FileAssociations {
}
pub fn get_icon(path: &Path, cx: &AppContext) -> Option<Arc<str>> {
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
let this = cx.try_global::<Self>()?;
// FIXME: Associate a type with the languages and have the file's language
// override these associations
@ -58,7 +58,7 @@ impl FileAssociations {
}
pub fn get_folder_icon(expanded: bool, cx: &AppContext) -> Option<Arc<str>> {
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
let this = cx.try_global::<Self>()?;
let key = if expanded {
EXPANDED_DIRECTORY_TYPE
@ -72,7 +72,7 @@ impl FileAssociations {
}
pub fn get_chevron_icon(expanded: bool, cx: &AppContext) -> Option<Arc<str>> {
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
let this = cx.try_global::<Self>()?;
let key = if expanded {
EXPANDED_CHEVRON_TYPE