move semantic search project intialization to a subscribe event for workspace created
Co-authored-by: Piotr <piotr@zed.dev>
This commit is contained in:
parent
e8e7b294d8
commit
a1519e4c38
2 changed files with 17 additions and 11 deletions
|
@ -35,6 +35,7 @@ use util::{
|
|||
paths::EMBEDDINGS_DIR,
|
||||
ResultExt,
|
||||
};
|
||||
use workspace::WorkspaceCreated;
|
||||
|
||||
const SEMANTIC_INDEX_VERSION: usize = 7;
|
||||
const EMBEDDINGS_BATCH_SIZE: usize = 80;
|
||||
|
@ -56,6 +57,22 @@ pub fn init(
|
|||
return;
|
||||
}
|
||||
|
||||
cx.subscribe_global::<WorkspaceCreated, _>({
|
||||
move |event, mut cx| {
|
||||
let Some(semantic_index) = SemanticIndex::global(cx) else { return; };
|
||||
let workspace = &event.0;
|
||||
if let Some(workspace) = workspace.upgrade(cx) {
|
||||
let project = workspace.read(cx).project().clone();
|
||||
if project.read(cx).is_local() {
|
||||
semantic_index.update(cx, |index, cx| {
|
||||
index.initialize_project(project, cx);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
cx.spawn(move |mut cx| async move {
|
||||
let semantic_index = SemanticIndex::new(
|
||||
fs,
|
||||
|
@ -133,7 +150,6 @@ impl ProjectState {
|
|||
async move {
|
||||
while let Ok(operation) = job_queue_rx.recv().await {
|
||||
Self::update_queue(&mut worktree_queue, operation);
|
||||
dbg!(worktree_queue.len());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue