Skip to content

Commit 4de1048

Browse files
authored
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 alacritty#4561.
1 parent f701b22 commit 4de1048

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Diff for: CHANGELOG.md

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

3839
### Removed
3940

Diff for: alacritty/src/config/mod.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,21 @@ pub fn load(options: &Options) -> Config {
100100
let config_options = options.config_options().clone();
101101
let config_path = options.config_path().or_else(installed_config);
102102

103-
if config_path.is_none() {
104-
info!(target: LOG_TARGET_CONFIG, "No config file found; using default");
105-
}
106-
107103
// Load the config using the following fallback behavior:
108104
// - Config path + CLI overrides
109105
// - CLI overrides
110106
// - Default
111107
let mut config = config_path
112-
.and_then(|config_path| load_from(&config_path, config_options.clone()).ok())
113-
.unwrap_or_else(|| Config::deserialize(config_options).unwrap_or_default());
108+
.as_ref()
109+
.and_then(|config_path| load_from(config_path, config_options.clone()).ok())
110+
.unwrap_or_else(|| {
111+
let mut config = Config::deserialize(config_options).unwrap_or_default();
112+
match config_path {
113+
Some(config_path) => config.ui_config.config_paths.push(config_path),
114+
None => info!(target: LOG_TARGET_CONFIG, "No config file found; using default"),
115+
}
116+
config
117+
});
114118

115119
// Override config with CLI options.
116120
options.override_config(&mut config);

0 commit comments

Comments
 (0)