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.
This commit is contained in:
Imbris 2023-05-01 11:51:41 -04:00 committed by GitHub
parent acb31c5322
commit 48e75d0559
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {