mirror of
https://github.com/encounter/objdiff.git
synced 2025-06-07 15:13:47 +00:00
Match watch_patterns with project-relative paths
This commit is contained in:
parent
21cdf268f0
commit
bf3ba48539
16
src/app.rs
16
src/app.rs
@ -375,19 +375,27 @@ fn create_watcher(
|
|||||||
) -> notify::Result<notify::RecommendedWatcher> {
|
) -> notify::Result<notify::RecommendedWatcher> {
|
||||||
let mut config_patterns = GlobSetBuilder::new();
|
let mut config_patterns = GlobSetBuilder::new();
|
||||||
for filename in CONFIG_FILENAMES {
|
for filename in CONFIG_FILENAMES {
|
||||||
config_patterns.add(Glob::new(&format!("**/{filename}")).unwrap());
|
config_patterns.add(Glob::new(filename).unwrap());
|
||||||
}
|
}
|
||||||
let config_patterns = config_patterns.build().unwrap();
|
let config_patterns = config_patterns.build().unwrap();
|
||||||
|
|
||||||
|
let base_dir = project_dir.to_owned();
|
||||||
let mut watcher =
|
let mut watcher =
|
||||||
notify::recommended_watcher(move |res: notify::Result<notify::Event>| match res {
|
notify::recommended_watcher(move |res: notify::Result<notify::Event>| match res {
|
||||||
Ok(event) => {
|
Ok(event) => {
|
||||||
if matches!(event.kind, notify::EventKind::Modify(..)) {
|
if matches!(
|
||||||
|
event.kind,
|
||||||
|
notify::EventKind::Modify(..)
|
||||||
|
| notify::EventKind::Create(..)
|
||||||
|
| notify::EventKind::Remove(..)
|
||||||
|
) {
|
||||||
for path in &event.paths {
|
for path in &event.paths {
|
||||||
|
let Ok(path) = path.strip_prefix(&base_dir) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
if config_patterns.is_match(path) {
|
if config_patterns.is_match(path) {
|
||||||
config_modified.store(true, Ordering::Relaxed);
|
config_modified.store(true, Ordering::Relaxed);
|
||||||
}
|
} else if patterns.is_match(path) {
|
||||||
if patterns.is_match(path) {
|
|
||||||
modified.store(true, Ordering::Relaxed);
|
modified.store(true, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user