mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-12 05:27:07 +00:00
Fix repo_for and clean up repository_entries
This commit is contained in:
parent
023d665fb3
commit
5b4e58d1de
1 changed files with 19 additions and 3 deletions
|
@ -1472,9 +1472,20 @@ impl Snapshot {
|
||||||
|
|
||||||
impl LocalSnapshot {
|
impl LocalSnapshot {
|
||||||
pub(crate) fn repo_for(&self, path: &Path) -> Option<RepositoryEntry> {
|
pub(crate) fn repo_for(&self, path: &Path) -> Option<RepositoryEntry> {
|
||||||
dbg!(&self.repository_entries)
|
let mut max_len = 0;
|
||||||
.closest(&RepositoryWorkDirectory(path.into()))
|
let mut current_candidate = None;
|
||||||
.map(|(_, entry)| entry.to_owned())
|
for (work_directory, repo) in (&self.repository_entries).iter() {
|
||||||
|
if work_directory.contains(path) {
|
||||||
|
if work_directory.0.as_os_str().len() > max_len {
|
||||||
|
current_candidate = Some(repo);
|
||||||
|
max_len = work_directory.0.as_os_str().len();
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
current_candidate.map(|entry| entry.to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn repo_for_metadata(
|
pub(crate) fn repo_for_metadata(
|
||||||
|
@ -2373,8 +2384,13 @@ impl BackgroundScanner {
|
||||||
git_repositories.retain(|project_entry_id, _| snapshot.contains_entry(*project_entry_id));
|
git_repositories.retain(|project_entry_id, _| snapshot.contains_entry(*project_entry_id));
|
||||||
snapshot.git_repositories = git_repositories;
|
snapshot.git_repositories = git_repositories;
|
||||||
|
|
||||||
|
let mut git_repository_entries = mem::take(&mut snapshot.snapshot.repository_entries);
|
||||||
|
git_repository_entries.retain(|_, entry| snapshot.contains_entry(entry.git_dir_entry_id));
|
||||||
|
snapshot.snapshot.repository_entries = git_repository_entries;
|
||||||
|
|
||||||
snapshot.removed_entry_ids.clear();
|
snapshot.removed_entry_ids.clear();
|
||||||
snapshot.completed_scan_id = snapshot.scan_id;
|
snapshot.completed_scan_id = snapshot.scan_id;
|
||||||
|
|
||||||
drop(snapshot);
|
drop(snapshot);
|
||||||
|
|
||||||
self.send_status_update(false, None);
|
self.send_status_update(false, None);
|
||||||
|
|
Loading…
Reference in a new issue