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 | |
| parent | fix(e2e): fix flaky locked mode test (#2413) (diff) | |
| download | sl0ppij-48e75d05596d58cfdb4e959d7cf571c3b4ed5038.tar.gz sl0ppij-48e75d05596d58cfdb4e959d7cf571c3b4ed5038.tar.xz sl0ppij-48e75d05596d58cfdb4e959d7cf571c3b4ed5038.zip | |
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.
| -rw-r--r-- | zellij-utils/src/setup.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/zellij-utils/src/setup.rs b/zellij-utils/src/setup.rs index a40df709..9127f70e 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()); + config.themes = get_default_themes().merge(config.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(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 { |
