mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-10 20:29:05 +00:00
add delete files operation for remaining files in database not included in current worktree
Co-authored-by: Piotr <piotr@zed.dev>
This commit is contained in:
parent
afe0e74868
commit
e8e7b294d8
1 changed files with 14 additions and 1 deletions
|
@ -797,6 +797,7 @@ impl SemanticIndex {
|
||||||
|
|
||||||
let language_registry = self.language_registry.clone();
|
let language_registry = self.language_registry.clone();
|
||||||
let parsing_files_tx = self.parsing_files_tx.clone();
|
let parsing_files_tx = self.parsing_files_tx.clone();
|
||||||
|
let db_update_tx = self.db_update_tx.clone();
|
||||||
|
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
futures::future::join_all(worktree_scans_complete).await;
|
futures::future::join_all(worktree_scans_complete).await;
|
||||||
|
@ -837,6 +838,7 @@ impl SemanticIndex {
|
||||||
let mut worktree_files = Vec::new();
|
let mut worktree_files = Vec::new();
|
||||||
for worktree in worktrees.into_iter() {
|
for worktree in worktrees.into_iter() {
|
||||||
let mut file_mtimes = worktree_file_mtimes.remove(&worktree.id()).unwrap();
|
let mut file_mtimes = worktree_file_mtimes.remove(&worktree.id()).unwrap();
|
||||||
|
let worktree_db_id = db_ids_by_worktree_id[&worktree.id()];
|
||||||
for file in worktree.files(false, 0) {
|
for file in worktree.files(false, 0) {
|
||||||
let absolute_path = worktree.absolutize(&file.path);
|
let absolute_path = worktree.absolutize(&file.path);
|
||||||
|
|
||||||
|
@ -869,7 +871,7 @@ impl SemanticIndex {
|
||||||
worktree_files.push(IndexOperation::IndexFile {
|
worktree_files.push(IndexOperation::IndexFile {
|
||||||
absolute_path: absolute_path.clone(),
|
absolute_path: absolute_path.clone(),
|
||||||
payload: PendingFile {
|
payload: PendingFile {
|
||||||
worktree_db_id: db_ids_by_worktree_id[&worktree.id()],
|
worktree_db_id,
|
||||||
relative_path: path_buf,
|
relative_path: path_buf,
|
||||||
absolute_path,
|
absolute_path,
|
||||||
language,
|
language,
|
||||||
|
@ -881,6 +883,17 @@ impl SemanticIndex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Clean up entries from database that are no longer in the worktree.
|
||||||
|
for (path, mtime) in file_mtimes {
|
||||||
|
worktree_files.push(IndexOperation::DeleteFile {
|
||||||
|
absolute_path: worktree.absolutize(path.as_path()),
|
||||||
|
payload: DbOperation::Delete {
|
||||||
|
worktree_id: worktree_db_id,
|
||||||
|
path,
|
||||||
|
},
|
||||||
|
tx: db_update_tx.clone(),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
anyhow::Ok(worktree_files)
|
anyhow::Ok(worktree_files)
|
||||||
|
|
Loading…
Reference in a new issue