Fix remote server crash with JSON files (#38678)

Closes #38594

Release Notes:

- N/A
This commit is contained in:
Julia Ryan 2025-09-22 17:30:27 -05:00 committed by GitHub
parent e9fbcf5abf
commit 5e502a32fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 6 deletions

View file

@ -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 {

View file

@ -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))));