diff --git a/assets/settings/default.json b/assets/settings/default.json index 4a21b708ee..b47f0dc2e7 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.rs index 511241bc22..cda37be601 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, 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>, + pub file_scan_exclusions: Option>, } #[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)] diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 6508a8635c..b05593cd4d 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, - scan_exclude_files: Vec, + file_scan_exclusions: Vec, } struct BackgroundScannerState { @@ -315,14 +315,14 @@ impl Worktree { Ok(cx.add_model(move |cx: &mut ModelContext| { let settings_subscription = cx.observe_global::(move |this, cx| { if let Self::Local(this) = this { - let new_scan_exclude_files = - scan_exclude_files(settings::get::(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::(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::>() @@ -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::(cx)), + file_scan_exclusions: file_scan_exclusions(settings::get::(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 { - project_settings.scan_exclude_files.as_deref().unwrap_or(&[]).iter() +fn file_scan_exclusions(project_settings: &ProjectSettings) -> Vec { + 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.rs index 256bc6477a..f66a71ee7d 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::(|store, cx| { store.update_user_settings::(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::(|store, cx| { store.update_user_settings::(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()]); }); }); });