diff options
Diffstat (limited to 'zellij-utils/src/setup.rs')
-rw-r--r-- | zellij-utils/src/setup.rs | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/zellij-utils/src/setup.rs b/zellij-utils/src/setup.rs index 0086c6a99..a40df7091 100644 --- a/zellij-utils/src/setup.rs +++ b/zellij-utils/src/setup.rs @@ -5,7 +5,7 @@ use crate::{ cli::{CliArgs, Command}, consts::{ FEATURES, SYSTEM_DEFAULT_CONFIG_DIR, SYSTEM_DEFAULT_DATA_DIR_PREFIX, VERSION, - ZELLIJ_PROJ_DIR, + ZELLIJ_DEFAULT_THEMES, ZELLIJ_PROJ_DIR, }, errors::prelude::*, input::{ @@ -63,6 +63,16 @@ pub fn get_default_data_dir() -> PathBuf { .unwrap_or_else(xdg_data_dir) } +#[cfg(not(test))] +fn get_default_themes() -> Themes { + ZELLIJ_DEFAULT_THEMES.to_owned() +} + +#[cfg(test)] +fn get_default_themes() -> Themes { + Themes::default() +} + pub fn xdg_config_dir() -> PathBuf { ZELLIJ_PROJ_DIR.config_dir().to_owned() } @@ -310,25 +320,13 @@ impl Setup { None => config.options.clone(), }; - if let Some(theme_dir) = config_options - .theme_dir - .clone() - .or_else(|| get_theme_dir(cli_args.config_dir.clone().or_else(find_default_config_dir))) - { - if theme_dir.is_dir() { - for entry in (theme_dir.read_dir()?).flatten() { - if let Some(extension) = entry.path().extension() { - if extension == "kdl" { - match Themes::from_path(entry.path()) { - Ok(themes) => config.themes = config.themes.merge(themes), - Err(e) => { - log::error!("error loading theme file: {:?}", e); - }, - } - } - } - } - } + config.themes = config.themes.merge(get_default_themes()); + + let user_theme_dir = config_options.theme_dir.clone().or_else(|| { + get_theme_dir(cli_args.config_dir.clone().or_else(find_default_config_dir)) + }); + if let Some(user_theme_dir) = user_theme_dir { + config.themes = config.themes.merge(Themes::from_dir(user_theme_dir)?); } if let Some(Command::Setup(ref setup)) = &cli_args.command { |