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
|
@ -844,16 +844,6 @@ impl ProjectSearchView {
|
|||
.detach();
|
||||
let filters_enabled = false;
|
||||
|
||||
// Initialize Semantic Index if Needed
|
||||
if SemanticIndex::enabled(cx) {
|
||||
let model = model.read(cx);
|
||||
project = model.project.clone();
|
||||
SemanticIndex::global(cx).map(|semantic| {
|
||||
dbg!("Initializing project");
|
||||
semantic.update(cx, |this, cx| this.initialize_project(project.clone(), cx));
|
||||
});
|
||||
}
|
||||
|
||||
// Check if Worktrees have all been previously indexed
|
||||
let mut this = ProjectSearchView {
|
||||
search_id: model.read(cx).search_id,
|
||||
|
|
|
@ -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