From 30a677e2576a9946362994c575fc295d51e36453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=8F=E7=99=BD?= <364772080@qq.com> Date: Sat, 24 Aug 2024 00:12:43 +0800 Subject: [PATCH] theme: Change autocomplete value for `*_font_fallbacks` (#16759) This PR follows up #16466, changes the default value used when autocompleting the `ui_font_fallbacks` and `ui_font_fallbacks` settings from `null` to `[]`. Special thanks to @maxdeviant for the guidance on writing better code! Release Notes: - N/A --- crates/theme/src/settings.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/theme/src/settings.rs b/crates/theme/src/settings.rs index 60f4768f06c1f17bbb4390665f4d416ae30eff1f..719e276c5752a681f7f8479922331a3f2550675a 100644 --- a/crates/theme/src/settings.rs +++ b/crates/theme/src/settings.rs @@ -247,6 +247,7 @@ pub struct ThemeSettingsContent { pub ui_font_family: Option, /// The font fallbacks to use for rendering in the UI. #[serde(default)] + #[schemars(default = "default_font_fallbacks")] pub ui_font_fallbacks: Option>, /// The OpenType features to enable for text in the UI. #[serde(default)] @@ -260,6 +261,7 @@ pub struct ThemeSettingsContent { pub buffer_font_family: Option, /// The font fallbacks to use for rendering in text buffers. #[serde(default)] + #[schemars(default = "default_font_fallbacks")] pub buffer_font_fallbacks: Option>, /// The default font size for rendering in text buffers. #[serde(default)] @@ -299,6 +301,10 @@ fn default_font_features() -> Option { Some(FontFeatures::default()) } +fn default_font_fallbacks() -> Option { + Some(FontFallbacks::default()) +} + impl ThemeSettingsContent { /// Sets the theme for the given appearance to the theme with the specified name. pub fn set_theme(&mut self, theme_name: String, appearance: Appearance) {