aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2022-11-15 09:10:08 -0500
committerGitHub <noreply@github.com>2022-11-15 14:10:08 +0000
commitd92a8a0e16eda3df7566e5c995aa0d258b6b76f7 (patch)
tree6adf44d797b8bb1e0842b59fd75473cacb7e08cd /alacritty/src
parent778558060243505d07b0850a115e3944862db5cd (diff)
downloadr-alacritty-d92a8a0e16eda3df7566e5c995aa0d258b6b76f7.tar.gz
r-alacritty-d92a8a0e16eda3df7566e5c995aa0d258b6b76f7.tar.bz2
r-alacritty-d92a8a0e16eda3df7566e5c995aa0d258b6b76f7.zip
Update to notify v5 via notify_debouncer_mini
Notify v5 moved the debounced API into the notify_debouncer_mini crate. The debounced API doesn't provide details on the type of event that happened, just that a list of events or errors happened. Therefore, reload is triggered on any event for a matching path. Co-authored-by: Christian Duerr <contact@christianduerr.com>
Diffstat (limited to 'alacritty/src')
-rw-r--r--alacritty/src/config/monitor.rs32
1 files changed, 15 insertions, 17 deletions
diff --git a/alacritty/src/config/monitor.rs b/alacritty/src/config/monitor.rs
index f6d52e2f..622a993b 100644
--- a/alacritty/src/config/monitor.rs
+++ b/alacritty/src/config/monitor.rs
@@ -3,7 +3,8 @@ use std::sync::mpsc;
use std::time::Duration;
use log::{debug, error};
-use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
+use notify_debouncer_mini::new_debouncer;
+use notify_debouncer_mini::notify::RecursiveMode;
use winit::event_loop::EventLoopProxy;
use alacritty_terminal::thread;
@@ -40,8 +41,8 @@ pub fn watch(mut paths: Vec<PathBuf>, event_proxy: EventLoopProxy<Event>) {
// The Duration argument is a debouncing period.
let (tx, rx) = mpsc::channel();
- let mut watcher = match watcher(tx, DEBOUNCE_DELAY) {
- Ok(watcher) => watcher,
+ let mut debouncer = match new_debouncer(DEBOUNCE_DELAY, None, tx) {
+ Ok(debouncer) => debouncer,
Err(err) => {
error!("Unable to watch config file: {}", err);
return;
@@ -61,6 +62,7 @@ pub fn watch(mut paths: Vec<PathBuf>, event_proxy: EventLoopProxy<Event>) {
parents.sort_unstable();
parents.dedup();
+ let watcher = debouncer.watcher();
// Watch all configuration file directories.
for parent in &parents {
if let Err(err) = watcher.watch(parent, RecursiveMode::NonRecursive) {
@@ -69,26 +71,22 @@ pub fn watch(mut paths: Vec<PathBuf>, event_proxy: EventLoopProxy<Event>) {
}
loop {
- let event = match rx.recv() {
- Ok(event) => event,
+ let events = match rx.recv() {
+ Ok(Ok(events)) => events,
+ Ok(Err(err)) => {
+ debug!("Config watcher errors: {:?}", err);
+ continue;
+ },
Err(err) => {
debug!("Config watcher channel dropped unexpectedly: {}", err);
break;
},
};
- match event {
- DebouncedEvent::Rename(_, path)
- | DebouncedEvent::Write(path)
- | DebouncedEvent::Create(path)
- | DebouncedEvent::Chmod(path)
- if paths.contains(&path) =>
- {
- // Always reload the primary configuration file.
- let event = Event::new(EventType::ConfigReload(paths[0].clone()), None);
- let _ = event_proxy.send_event(event);
- },
- _ => (),
+ if events.iter().any(|e| paths.contains(&e.path)) {
+ // Always reload the primary configuration file.
+ let event = Event::new(EventType::ConfigReload(paths[0].clone()), None);
+ let _ = event_proxy.send_event(event);
}
}
});