summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2019-02-02 12:03:03 +0000
committerGitHub <noreply@github.com>2019-02-02 12:03:03 +0000
commit53e491709d75477f8efe181315fe9301c6e845ba (patch)
treec623d886980b3db313721d5865d522e63dc01436 /src
parent863d5581a6b9917a4000d59f449653eb1ddd6dee (diff)
downloadalacritty-53e491709d75477f8efe181315fe9301c6e845ba.tar.gz
alacritty-53e491709d75477f8efe181315fe9301c6e845ba.zip
Fix reloading with empty config
When loading an empty configuration file, Alacritty only prints an info message and then proceeds to load the default config. However when reloading the configuration file it would throw a hard error. This has been fixed and a hard error is now only thrown when an error is returned during reload which isn't the empty file error.
Diffstat (limited to 'src')
-rw-r--r--src/config/mod.rs35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 63c72d34..d9717704 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -2224,18 +2224,31 @@ impl Monitor {
loop {
match rx.recv().expect("watcher event") {
DebouncedEvent::Rename(_, _) => continue,
- DebouncedEvent::Write(path) | DebouncedEvent::Create(path)
- | DebouncedEvent::Chmod(path) => {
- // Reload file
- if path == config_path {
- match Config::load_from(path) {
- Ok(config) => {
- let _ = config_tx.send(config);
- handler.on_config_reload();
- },
- Err(err) => error!("Ignoring invalid config: {}", err),
+ DebouncedEvent::Write(path)
+ | DebouncedEvent::Create(path)
+ | DebouncedEvent::Chmod(path) =>
+ {
+ if path != config_path {
+ continue;
+ }
+
+ let config = match Config::load_from(&path) {
+ Ok(config) => {
+ config
+ },
+ Err(err) => {
+ if let Error::Empty = err {
+ info!("Config file {:?} is empty; loading default", path);
+ Config::default()
+ } else {
+ error!("Ignoring invalid config: {}", err);
+ continue;
+ }
}
- }
+ };
+
+ let _ = config_tx.send(config);
+ handler.on_config_reload();
}
_ => {}
}