summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Bennett <me@phinary.ca>2019-03-06 18:38:55 +0000
committerShaun Bennett <me@phinary.ca>2019-03-06 18:38:55 +0000
commit04d0f78a2c3f326eae80c92ee6c83765bd4ce11e (patch)
tree8d600ca3fb62d2278824d555f63159b4cad22063
parent5d1d0407cac3219bfd3f5d3a5f0e39fb42005ae9 (diff)
Fix file watching for vim swap files
-rw-r--r--src/main.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 8f9ccea..de13f1c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,6 +3,7 @@ use crate::verify::verify;
use clap::{crate_version, App, Arg, SubCommand};
use notify::DebouncedEvent;
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
+use std::ffi::OsStr;
use std::io::BufRead;
use std::sync::mpsc::channel;
use std::time::Duration;
@@ -85,8 +86,10 @@ fn watch() -> notify::Result<()> {
loop {
match rx.recv() {
Ok(event) => match event {
- DebouncedEvent::Chmod(_) | DebouncedEvent::Write(_) => {
- let _ignored = verify();
+ DebouncedEvent::Create(b) | DebouncedEvent::Chmod(b) | DebouncedEvent::Write(b) => {
+ if b.extension() == Some(OsStr::new("rs")) {
+ let _ignored = verify();
+ }
}
_ => {}
},