Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix remote server crash with JSON files (#38678)
Julia Ryan5e502a32fbc5
diff --git a/crates/languages/src/json.rs b/crates/languages/src/json.rsindex 7e698cbf095..482c709d453 100644--- a/crates/languages/src/json.rs+++ b/crates/languages/src/json.rs@@ -157,12 +157,16 @@ impl JsonLspAdapter {) -> Value {let keymap_schema = KeymapFile::generate_json_schema_for_registered_actions(cx);let font_names = &cx.text_system().all_font_names();- let theme_names = &ThemeRegistry::global(cx).list_names();- let icon_theme_names = &ThemeRegistry::global(cx)- .list_icon_themes()- .into_iter()- .map(|icon_theme| icon_theme.name)- .collect::<Vec<SharedString>>();+ let themes = ThemeRegistry::try_global(cx);+ let theme_names = &themes.clone().map(|t| t.list_names()).unwrap_or_default();+ let icon_theme_names = &themes+ .map(|t| {+ t.list_icon_themes()+ .into_iter()+ .map(|icon_theme| icon_theme.name)+ .collect::<Vec<SharedString>>()+ })+ .unwrap_or_default();let settings_schema = cx.global::<SettingsStore>().json_schema(&SettingsJsonSchemaParams {diff --git a/crates/theme/src/registry.rs b/crates/theme/src/registry.rsindex 8bf8481c84c..c362b627042 100644--- a/crates/theme/src/registry.rs+++ b/crates/theme/src/registry.rs@@ -73,6 +73,11 @@ impl ThemeRegistry {cx.default_global::<GlobalThemeRegistry>().0.clone()}+ /// Returns the global [`ThemeRegistry`] if it exists.+ pub fn try_global(cx: &mut App) -> Option<Arc<Self>> {+ cx.try_global::<GlobalThemeRegistry>().map(|t| t.0.clone())+ }+/// Sets the global [`ThemeRegistry`].pub(crate) fn set_global(assets: Box<dyn AssetSource>, cx: &mut App) {cx.set_global(GlobalThemeRegistry(Arc::new(ThemeRegistry::new(assets))));