Use a better name
This commit is contained in:
parent
5f468970f0
commit
30fefa0ef8
4 changed files with 19 additions and 19 deletions
|
@ -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": {
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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()]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue