Fix the regex matcher
This commit is contained in:
parent
f0ca7141b8
commit
2c2c14a360
4 changed files with 41 additions and 17 deletions
|
@ -223,7 +223,7 @@ impl PathMatcher {
|
|||
pub fn is_match<P: AsRef<Path>>(&self, other: P) -> bool {
|
||||
let other_path = other.as_ref();
|
||||
other_path.starts_with(&self.maybe_path)
|
||||
|| other_path.file_name() == Some(self.maybe_path.as_os_str())
|
||||
|| other_path.ends_with(&self.maybe_path)
|
||||
|| self.glob.is_match(other_path)
|
||||
|| self.check_with_end_separator(other_path)
|
||||
}
|
||||
|
@ -422,4 +422,14 @@ mod tests {
|
|||
"Path matcher {path_matcher} should match {path:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_search() {
|
||||
let path = Path::new("/Users/someonetoignore/work/zed/zed.dev/node_modules");
|
||||
let path_matcher = PathMatcher::new("**/node_modules/**").unwrap();
|
||||
assert!(
|
||||
path_matcher.is_match(&path),
|
||||
"Path matcher {path_matcher} should match {path:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue