Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use a better name
Kirill Bulatov30fefa0ef8a0
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex 4a21b708eef..b47f0dc2e7e 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -269,7 +269,7 @@"include_warnings": true},// TODO kb docs- "scan_exclude_files": [+ "file_scan_exclusions": ["**/.git","**/.svn","**/.hg",@@ -277,8 +277,7 @@"**/.DS_Store","**/Thumbs.db","**/.classpath",- "**/.settings",- "**/target"+ "**/.settings"],// Git gutter behavior configuration."git": {diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rsindex 511241bc22d..cda37be601c 100644--- a/crates/project/src/project_settings.rs+++ b/crates/project/src/project_settings.rs@@ -10,9 +10,9 @@ pub struct ProjectSettings {pub lsp: HashMap<Arc<str>, LspSettings>,#[serde(default)]pub git: GitSettings,- // TODO kb better names and docs and tests+ // TODO kb docs and project_search test#[serde(default)]- pub scan_exclude_files: Option<Vec<String>>,+ pub file_scan_exclusions: Option<Vec<String>>,}#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rsindex 6508a8635c7..b05593cd4df 100644--- a/crates/project/src/worktree.rs+++ b/crates/project/src/worktree.rs@@ -225,7 +225,7 @@ pub struct LocalSnapshot {/// All of the git repositories in the worktree, indexed by the project entry/// id of their parent directory.git_repositories: TreeMap<ProjectEntryId, LocalRepositoryEntry>,- scan_exclude_files: Vec<PathMatcher>,+ file_scan_exclusions: Vec<PathMatcher>,}struct BackgroundScannerState {@@ -315,14 +315,14 @@ impl Worktree {Ok(cx.add_model(move |cx: &mut ModelContext<Worktree>| {let settings_subscription = cx.observe_global::<SettingsStore, _>(move |this, cx| {if let Self::Local(this) = this {- let new_scan_exclude_files =- scan_exclude_files(settings::get::<ProjectSettings>(cx));- if new_scan_exclude_files != this.snapshot.scan_exclude_files {- this.snapshot.scan_exclude_files = new_scan_exclude_files;+ let new_file_scan_exclusions =+ file_scan_exclusions(settings::get::<ProjectSettings>(cx));+ if new_file_scan_exclusions != this.snapshot.file_scan_exclusions {+ this.snapshot.file_scan_exclusions = new_file_scan_exclusions;log::info!("Re-scanning directories, new scan exclude files: {:?}",this.snapshot- .scan_exclude_files+ .file_scan_exclusions.iter().map(ToString::to_string).collect::<Vec<_>>()@@ -351,7 +351,7 @@ impl Worktree {.file_name().map_or(String::new(), |f| f.to_string_lossy().to_string());let mut snapshot = LocalSnapshot {- scan_exclude_files: scan_exclude_files(settings::get::<ProjectSettings>(cx)),+ file_scan_exclusions: file_scan_exclusions(settings::get::<ProjectSettings>(cx)),ignores_by_parent_abs_path: Default::default(),git_repositories: Default::default(),snapshot: Snapshot {@@ -648,15 +648,15 @@ fn start_background_scan_tasks(vec![background_scanner, scan_state_updater]}-fn scan_exclude_files(project_settings: &ProjectSettings) -> Vec<PathMatcher> {- project_settings.scan_exclude_files.as_deref().unwrap_or(&[]).iter()+fn file_scan_exclusions(project_settings: &ProjectSettings) -> Vec<PathMatcher> {+ project_settings.file_scan_exclusions.as_deref().unwrap_or(&[]).iter().sorted().filter_map(|pattern| {PathMatcher::new(pattern).map(Some).unwrap_or_else(|e| {log::error!(- "Skipping pattern {pattern} in `scan_exclude_files` project settings due to parsing error: {e:#}"+ "Skipping pattern {pattern} in `file_scan_exclusions` project settings due to parsing error: {e:#}");None})@@ -2227,7 +2227,7 @@ impl LocalSnapshot {}fn is_abs_path_excluded(&self, abs_path: &Path) -> bool {- self.scan_exclude_files+ self.file_scan_exclusions.iter().any(|exclude_matcher| exclude_matcher.is_match(abs_path))}diff --git a/crates/project/src/worktree_tests.rs b/crates/project/src/worktree_tests.rsindex 256bc6477a7..f66a71ee7d5 100644--- a/crates/project/src/worktree_tests.rs+++ b/crates/project/src/worktree_tests.rs@@ -888,7 +888,7 @@ async fn test_write_file(cx: &mut TestAppContext) {}#[gpui::test]-async fn test_ignore_exclusions(cx: &mut TestAppContext) {+async fn test_file_scan_exclusions(cx: &mut TestAppContext) {init_test(cx);let dir = temp_tree(json!({".gitignore": "**/target\n/node_modules\n",@@ -917,7 +917,7 @@ async fn test_ignore_exclusions(cx: &mut TestAppContext) {cx.update(|cx| {cx.update_global::<SettingsStore, _, _>(|store, cx| {store.update_user_settings::<ProjectSettings>(cx, |project_settings| {- project_settings.scan_exclude_files =+ project_settings.file_scan_exclusions =Some(vec!["**/foo/**".to_string(), "**/.DS_Store".to_string()]);});});@@ -954,7 +954,8 @@ async fn test_ignore_exclusions(cx: &mut TestAppContext) {cx.update(|cx| {cx.update_global::<SettingsStore, _, _>(|store, cx| {store.update_user_settings::<ProjectSettings>(cx, |project_settings| {- project_settings.scan_exclude_files = Some(vec!["**/node_modules/**".to_string()]);+ project_settings.file_scan_exclusions =+ Some(vec!["**/node_modules/**".to_string()]);});});});