From 48e75d05596d58cfdb4e959d7cf571c3b4ed5038 Mon Sep 17 00:00:00 2001 From: Imbris <2002109+Imberflur@users.noreply.github.com> Date: Mon, 1 May 2023 11:51:41 -0400 Subject: Fix error loading non-existant themes directory and use default themes as the base when merging (#2411) * Fix error loading non-existant themes directory If the themes directory is derived from the config directory (rather than being specified explicitly in the config_options), we will avoid trying to load from it if it doesn't exist. * Use default themes as the base when merging with the themes specified in the config. This avoids the default themes overriding themes specified in the config. * If `setup --clean` is used, avoid loading from the user's theme directory. --- zellij-utils/src/setup.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'zellij-utils') diff --git a/zellij-utils/src/setup.rs b/zellij-utils/src/setup.rs index a40df7091..9127f70ec 100644 --- a/zellij-utils/src/setup.rs +++ b/zellij-utils/src/setup.rs @@ -320,13 +320,18 @@ impl Setup { None => config.options.clone(), }; - 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)?); + config.themes = get_default_themes().merge(config.themes); + + if let Some(Command::Setup(Setup { clean: false, .. })) = &cli_args.command { + 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 theme dir is not explicitly specified in config_options, + // only try to use it if it exists. + .filter(|dir| dir.exists()) + }); + 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 { -- cgit v1.2.3