hardcode ".git" and "node_modules" also

This commit is contained in:
Bernardo 2019-01-22 18:14:31 +01:00 committed by Aleksey Kladov
parent 10a24cf649
commit 0a08650852
2 changed files with 10 additions and 2 deletions

View File

@ -132,7 +132,7 @@ fn handle_task(task: Task, watcher: &Arc<Mutex<Option<Watcher>>>) -> TaskResult
root_filter,
nested_roots,
} => {
watch(watcher, &path, &*root_filter, false);
watch(watcher, &path, root_filter.as_ref(), false);
log::debug!("loading {} ...", path.as_path().display());
let files = load_root(
path.as_path(),

View File

@ -59,7 +59,15 @@ impl RootFilter {
pub(crate) fn default_filter(path: &Path, rel_path: &RelativePath) -> bool {
if path.is_dir() {
rel_path.components().next() != Some(Component::Normal("target"))
for (i, c) in rel_path.components().enumerate() {
if let Component::Normal(c) = c {
// hardcoded for now
if (i == 0 && c == "target") || c == ".git" || c == "node_modules" {
return false;
}
}
}
true
} else {
rel_path.extension() == Some("rs")
}