util: Move PathMatcher over to RelPath (#43881)
Closes https://github.com/zed-industries/zed/issues/40688 Closes https://github.com/zed-industries/zed/issues/41242 Release Notes: - Fixed project search not working correctly on remotes where the host and remote path styles differ
This commit is contained in:
@@ -5509,7 +5509,7 @@ impl TryFrom<(&CharBag, &PathMatcher, proto::Entry)> for Entry {
|
||||
let path =
|
||||
RelPath::from_proto(&entry.path).context("invalid relative path in proto message")?;
|
||||
let char_bag = char_bag_for_path(*root_char_bag, &path);
|
||||
let is_always_included = always_included.is_match(path.as_std_path());
|
||||
let is_always_included = always_included.is_match(&path);
|
||||
Ok(Entry {
|
||||
id: ProjectEntryId::from_proto(entry.id),
|
||||
kind,
|
||||
|
||||
@@ -25,25 +25,25 @@ pub struct WorktreeSettings {
|
||||
impl WorktreeSettings {
|
||||
pub fn is_path_private(&self, path: &RelPath) -> bool {
|
||||
path.ancestors()
|
||||
.any(|ancestor| self.private_files.is_match(ancestor.as_std_path()))
|
||||
.any(|ancestor| self.private_files.is_match(ancestor))
|
||||
}
|
||||
|
||||
pub fn is_path_excluded(&self, path: &RelPath) -> bool {
|
||||
path.ancestors()
|
||||
.any(|ancestor| self.file_scan_exclusions.is_match(ancestor.as_std_path()))
|
||||
.any(|ancestor| self.file_scan_exclusions.is_match(ancestor))
|
||||
}
|
||||
|
||||
pub fn is_path_always_included(&self, path: &RelPath, is_dir: bool) -> bool {
|
||||
if is_dir {
|
||||
self.parent_dir_scan_inclusions.is_match(path.as_std_path())
|
||||
self.parent_dir_scan_inclusions.is_match(path)
|
||||
} else {
|
||||
self.file_scan_inclusions.is_match(path.as_std_path())
|
||||
self.file_scan_inclusions.is_match(path)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_path_hidden(&self, path: &RelPath) -> bool {
|
||||
path.ancestors()
|
||||
.any(|ancestor| self.hidden_files.is_match(ancestor.as_std_path()))
|
||||
.any(|ancestor| self.hidden_files.is_match(ancestor))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user