summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-09-20 09:58:39 +0000
committerGitHub <noreply@github.com>2020-09-20 09:58:39 +0000
commit539855cdb92c44dc0f755e6ea6debcf13a77f049 (patch)
treed9b399e706f2ac6ee28536fdd4f19d2f364b6bc8
parent56cff184868f3bb3bb45082cac79fec296e4a48b (diff)
downloadalacritty-539855cdb92c44dc0f755e6ea6debcf13a77f049.tar.gz
alacritty-539855cdb92c44dc0f755e6ea6debcf13a77f049.zip
Fix CLI arguments without config file
Since we only applied the CLI arguments as overrides to the configuration file after the file was loaded, all CLI arguments that are stored on the config would be dropped without a configuration file in place. This also makes sure that all configuration file config overrides are still loaded if the configuration file could not be loaded for any reason, since there's no reason why we'd just drop everything in that case.
-rw-r--r--alacritty/src/config/mod.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/alacritty/src/config/mod.rs b/alacritty/src/config/mod.rs
index 56a12c7c..d268d921 100644
--- a/alacritty/src/config/mod.rs
+++ b/alacritty/src/config/mod.rs
@@ -97,18 +97,20 @@ impl From<serde_yaml::Error> for Error {
/// Load the configuration file.
pub fn load(options: &Options) -> Config {
- // Get config path.
- let config_path = match options.config_path().or_else(installed_config) {
- Some(path) => path,
- None => {
- info!(target: LOG_TARGET_CONFIG, "No config file found; using default");
- return Config::default();
- },
- };
-
- // Load config, falling back to the default on error.
let config_options = options.config_options().clone();
- let mut config = load_from(&config_path, config_options).unwrap_or_default();
+ let config_path = options.config_path().or_else(installed_config);
+
+ if config_path.is_none() {
+ info!(target: LOG_TARGET_CONFIG, "No config file found; using default");
+ }
+
+ // Load the config using the following fallback behavior:
+ // - Config path + CLI overrides
+ // - CLI overrides
+ // - Default
+ let mut config = config_path
+ .and_then(|config_path| load_from(&config_path, config_options.clone()).ok())
+ .unwrap_or_else(|| Config::deserialize(config_options).unwrap_or_default());
// Override config with CLI options.
options.override_config(&mut config);