diff options
author | Imbris <2002109+Imberflur@users.noreply.github.com> | 2023-05-01 11:51:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-02 00:51:41 +0900 |
commit | 48e75d05596d58cfdb4e959d7cf571c3b4ed5038 (patch) | |
tree | de11e4c66e1f7787824eb4e22858a14e9bc13356 /zellij-utils | |
parent | acb31c5322b1ffb30420cb6171f50a8e5944d013 (diff) |
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.
Diffstat (limited to 'zellij-utils')
-rw-r--r-- | zellij-utils/src/setup.rs | 19 |
1 files changed, 12 insertions, 7 deletions
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 { |