diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 83722f81bcf..4af79e9884f 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -5418,6 +5418,8 @@ impl BackgroundScanner { root_char_bag = snapshot.root_char_bag; } + let parent_is_private = self.is_path_private(&job.path); + let parent_is_hidden = self.settings.is_path_hidden(&job.path); let next_entry_id = self.next_entry_id.clone(); let mut ignore_stack = job.ignore_stack.clone(); let mut new_ignore = None; @@ -5539,7 +5541,8 @@ impl BackgroundScanner { } } - if self.settings.is_path_excluded(&child_path) { + // `job.path` was checked above, so only the child can match. + if self.settings.file_scan_exclusions.is_match(&child_path) { log::debug!("skipping excluded child entry {child_path:?}"); self.state @@ -5643,18 +5646,16 @@ impl BackgroundScanner { self.settings.is_path_always_included(&child_path, false); } + if parent_is_private + || (!self.share_private_files + && self.settings.private_files.is_match(&child_entry.path)) { - let relative_path = job - .path - .join(RelPath::from_unix_str(child_name.to_str().unwrap()).unwrap()); - if self.is_path_private(&relative_path) { - log::debug!("detected private file: {relative_path:?}"); - child_entry.is_private = true; - } - if self.settings.is_path_hidden(&relative_path) { - log::debug!("detected hidden file: {relative_path:?}"); - child_entry.is_hidden = true; - } + log::debug!("detected private file: {:?}", child_entry.path); + child_entry.is_private = true; + } + if parent_is_hidden || self.settings.hidden_files.is_match(&child_entry.path) { + log::debug!("detected hidden file: {:?}", child_entry.path); + child_entry.is_hidden = true; } new_entries.push(child_entry);