mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Retrieve embeddings based on pending files
Co-Authored-By: Kyle Caverly <kyle@zed.dev>
This commit is contained in:
parent
7b5a41dda2
commit
6b1dc63fc0
@ -417,7 +417,7 @@ impl SemanticIndex {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
worktree_state.paths_changed(changes, Instant::now(), worktree);
|
worktree_state.paths_changed(changes, Instant::now(), worktree);
|
||||||
if let WorktreeState::Registered(worktree_state) = worktree_state {
|
if let WorktreeState::Registered(_) = worktree_state {
|
||||||
cx.spawn_weak(|this, mut cx| async move {
|
cx.spawn_weak(|this, mut cx| async move {
|
||||||
cx.background().timer(BACKGROUND_INDEXING_DELAY).await;
|
cx.background().timer(BACKGROUND_INDEXING_DELAY).await;
|
||||||
if let Some((this, project)) = this.upgrade(&cx).zip(project.upgrade(&cx)) {
|
if let Some((this, project)) = this.upgrade(&cx).zip(project.upgrade(&cx)) {
|
||||||
@ -842,18 +842,6 @@ impl SemanticIndex {
|
|||||||
true
|
true
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut worktree_id_file_paths = HashMap::default();
|
|
||||||
for worktree in project_state.worktrees.values() {
|
|
||||||
if let WorktreeState::Registered(worktree_state) = worktree {
|
|
||||||
for (path, _) in &worktree_state.changed_paths {
|
|
||||||
worktree_id_file_paths
|
|
||||||
.entry(worktree_state.db_id)
|
|
||||||
.or_insert(Vec::new())
|
|
||||||
.push(path.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let db = self.db.clone();
|
let db = self.db.clone();
|
||||||
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();
|
||||||
@ -862,12 +850,21 @@ impl SemanticIndex {
|
|||||||
db.delete_file(worktree_db_id, path).await.log_err();
|
db.delete_file(worktree_db_id, path).await.log_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
let embeddings_for_digest = Arc::new(
|
let embeddings_for_digest = {
|
||||||
db.embeddings_for_files(worktree_id_file_paths)
|
let mut files = HashMap::default();
|
||||||
.await
|
for pending_file in &pending_files {
|
||||||
.log_err()
|
files
|
||||||
.unwrap_or_default(),
|
.entry(pending_file.worktree_db_id)
|
||||||
);
|
.or_insert(Vec::new())
|
||||||
|
.push(pending_file.relative_path.clone());
|
||||||
|
}
|
||||||
|
Arc::new(
|
||||||
|
db.embeddings_for_files(files)
|
||||||
|
.await
|
||||||
|
.log_err()
|
||||||
|
.unwrap_or_default(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
for mut pending_file in pending_files {
|
for mut pending_file in pending_files {
|
||||||
if let Ok(language) = language_registry
|
if let Ok(language) = language_registry
|
||||||
|
Loading…
Reference in New Issue
Block a user