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
|
"include_warnings": true
|
||||||
},
|
},
|
||||||
// TODO kb docs
|
// TODO kb docs
|
||||||
"scan_exclude_files": [
|
"file_scan_exclusions": [
|
||||||
"**/.git",
|
"**/.git",
|
||||||
"**/.svn",
|
"**/.svn",
|
||||||
"**/.hg",
|
"**/.hg",
|
||||||
|
@ -277,8 +277,7 @@
|
||||||
"**/.DS_Store",
|
"**/.DS_Store",
|
||||||
"**/Thumbs.db",
|
"**/Thumbs.db",
|
||||||
"**/.classpath",
|
"**/.classpath",
|
||||||
"**/.settings",
|
"**/.settings"
|
||||||
"**/target"
|
|
||||||
],
|
],
|
||||||
// Git gutter behavior configuration.
|
// Git gutter behavior configuration.
|
||||||
"git": {
|
"git": {
|
||||||
|
|
|
@ -10,9 +10,9 @@ pub struct ProjectSettings {
|
||||||
pub lsp: HashMap<Arc<str>, LspSettings>,
|
pub lsp: HashMap<Arc<str>, LspSettings>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub git: GitSettings,
|
pub git: GitSettings,
|
||||||
// TODO kb better names and docs and tests
|
// TODO kb docs and project_search test
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub scan_exclude_files: Option<Vec<String>>,
|
pub file_scan_exclusions: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
#[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
|
/// All of the git repositories in the worktree, indexed by the project entry
|
||||||
/// id of their parent directory.
|
/// id of their parent directory.
|
||||||
git_repositories: TreeMap<ProjectEntryId, LocalRepositoryEntry>,
|
git_repositories: TreeMap<ProjectEntryId, LocalRepositoryEntry>,
|
||||||
scan_exclude_files: Vec<PathMatcher>,
|
file_scan_exclusions: Vec<PathMatcher>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BackgroundScannerState {
|
struct BackgroundScannerState {
|
||||||
|
@ -315,14 +315,14 @@ impl Worktree {
|
||||||
Ok(cx.add_model(move |cx: &mut ModelContext<Worktree>| {
|
Ok(cx.add_model(move |cx: &mut ModelContext<Worktree>| {
|
||||||
let settings_subscription = cx.observe_global::<SettingsStore, _>(move |this, cx| {
|
let settings_subscription = cx.observe_global::<SettingsStore, _>(move |this, cx| {
|
||||||
if let Self::Local(this) = this {
|
if let Self::Local(this) = this {
|
||||||
let new_scan_exclude_files =
|
let new_file_scan_exclusions =
|
||||||
scan_exclude_files(settings::get::<ProjectSettings>(cx));
|
file_scan_exclusions(settings::get::<ProjectSettings>(cx));
|
||||||
if new_scan_exclude_files != this.snapshot.scan_exclude_files {
|
if new_file_scan_exclusions != this.snapshot.file_scan_exclusions {
|
||||||
this.snapshot.scan_exclude_files = new_scan_exclude_files;
|
this.snapshot.file_scan_exclusions = new_file_scan_exclusions;
|
||||||
log::info!(
|
log::info!(
|
||||||
"Re-scanning directories, new scan exclude files: {:?}",
|
"Re-scanning directories, new scan exclude files: {:?}",
|
||||||
this.snapshot
|
this.snapshot
|
||||||
.scan_exclude_files
|
.file_scan_exclusions
|
||||||
.iter()
|
.iter()
|
||||||
.map(ToString::to_string)
|
.map(ToString::to_string)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
@ -351,7 +351,7 @@ impl Worktree {
|
||||||
.file_name()
|
.file_name()
|
||||||
.map_or(String::new(), |f| f.to_string_lossy().to_string());
|
.map_or(String::new(), |f| f.to_string_lossy().to_string());
|
||||||
let mut snapshot = LocalSnapshot {
|
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(),
|
ignores_by_parent_abs_path: Default::default(),
|
||||||
git_repositories: Default::default(),
|
git_repositories: Default::default(),
|
||||||
snapshot: Snapshot {
|
snapshot: Snapshot {
|
||||||
|
@ -648,15 +648,15 @@ fn start_background_scan_tasks(
|
||||||
vec![background_scanner, scan_state_updater]
|
vec![background_scanner, scan_state_updater]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scan_exclude_files(project_settings: &ProjectSettings) -> Vec<PathMatcher> {
|
fn file_scan_exclusions(project_settings: &ProjectSettings) -> Vec<PathMatcher> {
|
||||||
project_settings.scan_exclude_files.as_deref().unwrap_or(&[]).iter()
|
project_settings.file_scan_exclusions.as_deref().unwrap_or(&[]).iter()
|
||||||
.sorted()
|
.sorted()
|
||||||
.filter_map(|pattern| {
|
.filter_map(|pattern| {
|
||||||
PathMatcher::new(pattern)
|
PathMatcher::new(pattern)
|
||||||
.map(Some)
|
.map(Some)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
log::error!(
|
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
|
None
|
||||||
})
|
})
|
||||||
|
@ -2227,7 +2227,7 @@ impl LocalSnapshot {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_abs_path_excluded(&self, abs_path: &Path) -> bool {
|
fn is_abs_path_excluded(&self, abs_path: &Path) -> bool {
|
||||||
self.scan_exclude_files
|
self.file_scan_exclusions
|
||||||
.iter()
|
.iter()
|
||||||
.any(|exclude_matcher| exclude_matcher.is_match(abs_path))
|
.any(|exclude_matcher| exclude_matcher.is_match(abs_path))
|
||||||
}
|
}
|
||||||
|
|
|
@ -888,7 +888,7 @@ async fn test_write_file(cx: &mut TestAppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_ignore_exclusions(cx: &mut TestAppContext) {
|
async fn test_file_scan_exclusions(cx: &mut TestAppContext) {
|
||||||
init_test(cx);
|
init_test(cx);
|
||||||
let dir = temp_tree(json!({
|
let dir = temp_tree(json!({
|
||||||
".gitignore": "**/target\n/node_modules\n",
|
".gitignore": "**/target\n/node_modules\n",
|
||||||
|
@ -917,7 +917,7 @@ async fn test_ignore_exclusions(cx: &mut TestAppContext) {
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
cx.update_global::<SettingsStore, _, _>(|store, cx| {
|
cx.update_global::<SettingsStore, _, _>(|store, cx| {
|
||||||
store.update_user_settings::<ProjectSettings>(cx, |project_settings| {
|
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()]);
|
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(|cx| {
|
||||||
cx.update_global::<SettingsStore, _, _>(|store, cx| {
|
cx.update_global::<SettingsStore, _, _>(|store, cx| {
|
||||||
store.update_user_settings::<ProjectSettings>(cx, |project_settings| {
|
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