Fix live reload with broken yaml on start

Since the current behavior would just load the default configuration
file whenever the configuration file couldn't be loaded, the path was
not set to any value. As a result however, the live config reload
feature would not work with a broken yaml (one which cannot be
deserialized, not one with warnings).

If a configuration file has been specified, but the deserialization
still failed, the path is now preserved on the default configuration
file to make it possible to live reload a fix for the issue.

Fixes #4561.
This commit is contained in:
Christian Duerr 2020-12-14 00:22:16 +00:00 committed by GitHub
parent f701b22c2d
commit 4de1048628
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View file

@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Window not being completely opaque on Windows
- Window being always on top during alt-tab on Windows
- Cursor position not reported to apps when mouse is moved with button held outside of window
- No live config update when starting Alacritty with a broken configuration file
### Removed

View file

@ -100,17 +100,21 @@ pub fn load(options: &Options) -> Config {
let config_options = options.config_options().clone();
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());
.as_ref()
.and_then(|config_path| load_from(config_path, config_options.clone()).ok())
.unwrap_or_else(|| {
let mut config = Config::deserialize(config_options).unwrap_or_default();
match config_path {
Some(config_path) => config.ui_config.config_paths.push(config_path),
None => info!(target: LOG_TARGET_CONFIG, "No config file found; using default"),
}
config
});
// Override config with CLI options.
options.override_config(&mut config);