Skip to content

Instantly share code, notes, and snippets.

@mgax

mgax/match.diff Secret

Created July 3, 2023 07:11
Show Gist options
  • Save mgax/0506394f61f5d47f856803cc52213a7a to your computer and use it in GitHub Desktop.
Save mgax/0506394f61f5d47f856803cc52213a7a to your computer and use it in GitHub Desktop.
diff --git a/src/window/mod.rs b/src/window/mod.rs
index 75a5a62..8cd3090 100644
--- a/src/window/mod.rs
+++ b/src/window/mod.rs
@@ -207,10 +207,10 @@ impl WinitWindowWrapper {
} => {
let cmd_line_settings = SETTINGS.get::<CmdLineSettings>();
if cmd_line_settings.theme == Some(ThemeChoice::Auto) {
- match theme {
- Theme::Light => set_background("light"),
- Theme::Dark => set_background("dark"),
- };
+ set_background(match theme {
+ Theme::Light => "light",
+ Theme::Dark => "dark",
+ });
}
}
Event::RedrawRequested(..) | Event::WindowEvent { .. } => {
@@ -478,16 +478,19 @@ pub fn create_window() {
renderer.grid_renderer.font_dimensions,
);
- match cmd_line_settings.theme {
- None => {}
- Some(ThemeChoice::Light) => set_background("light"),
- Some(ThemeChoice::Dark) => set_background("dark"),
- Some(ThemeChoice::Auto) => match window.theme() {
- Some(Theme::Light) => set_background("light"),
- Some(Theme::Dark) => set_background("dark"),
- None => {}
- },
- };
+ if let Some(theme) = cmd_line_settings.theme {
+ if let Some(background) = match theme {
+ ThemeChoice::Light => Some("light"),
+ ThemeChoice::Dark => Some("dark"),
+ ThemeChoice::Auto => match window.theme() {
+ Some(Theme::Light) => Some("light"),
+ Some(Theme::Dark) => Some("dark"),
+ None => None
+ },
+ } {
+ set_background(background);
+ }
+ }
let mut window_wrapper = WinitWindowWrapper {
windowed_context,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment