Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8f50cd8
Add benchmark for project search
osiewicz Oct 15, 2025
3afd13f
Start
osiewicz Oct 9, 2025
11505e2
WIP
osiewicz Oct 10, 2025
1eff3a3
One step at a time
osiewicz Oct 10, 2025
e5bec60
Another one
osiewicz Oct 10, 2025
f7f79f6
Wire up searcher (incomplete one) to main search routine
osiewicz Oct 10, 2025
0f5bfb6
WTF, it works
osiewicz Oct 10, 2025
50d6b45
Clean up a bunch of warnings
osiewicz Oct 15, 2025
a4d9a3b
Clean up a few more imports
osiewicz Oct 15, 2025
e9956a5
Make the search terminate
osiewicz Oct 15, 2025
0d5c990
Start exploring API for remote searches
osiewicz Oct 16, 2025
86f61e5
Send ignored buffers to the front
osiewicz Oct 16, 2025
ef7a1dc
clippy
osiewicz Oct 16, 2025
5035474
Clean up lifetime of queues
osiewicz Oct 16, 2025
71ac9aa
:facepalm: Fixed test_search test.
osiewicz Oct 16, 2025
ae2aeb6
Reduce count of threads running the search to avoid oversubscribing.
osiewicz Oct 16, 2025
d8603e8
Fix traversal of ignored directories for test
osiewicz Oct 16, 2025
2f5af65
Merge branch 'main' into search-v10000000
osiewicz Oct 16, 2025
b3ee8c7
clippy
osiewicz Oct 16, 2025
325dcde
Iterate on CI fixes
osiewicz Oct 16, 2025
403edbd
Fix leaked handle
osiewicz Oct 16, 2025
0301336
Merge branch 'main' into search-v10000000
osiewicz Oct 16, 2025
c5e2091
Merge branch 'main' into search-v10000000
osiewicz Oct 16, 2025
cd3f219
Load buffers concurrently
osiewicz Oct 17, 2025
7200ce7
Start feeding buffers back even before we have all of them
osiewicz Oct 17, 2025
94edbae
Merge branch 'main' into search-v10000000
osiewicz Oct 20, 2025
3d51b11
Merge branch 'main' into search-v10000000
osiewicz Oct 20, 2025
f93a3b5
Start on remote counterpart
osiewicz Oct 20, 2025
6257df8
Fix searching in collab scenarios
osiewicz Oct 20, 2025
e295fb6
Fix remote-server tests build features (enabled test-support for agent)
osiewicz Oct 20, 2025
73a1549
Fix project search in remote projects
osiewicz Oct 20, 2025
b9862d6
Merge branch 'main' into search-v10000000
osiewicz Oct 20, 2025
151c7b3
Fix searching within open buffers only
osiewicz Oct 20, 2025
8cb6387
A couple of styling changes
osiewicz Oct 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ members = [
"crates/picker",
"crates/prettier",
"crates/project",
"crates/project_benchmarks",
"crates/project_panel",
"crates/project_symbols",
"crates/prompt_store",
Expand Down Expand Up @@ -194,6 +195,7 @@ members = [
"crates/web_search_providers",
"crates/workspace",
"crates/worktree",
"crates/worktree_benchmarks",
"crates/x_ai",
"crates/zed",
"crates/zed_actions",
Expand Down
71 changes: 8 additions & 63 deletions crates/project/src/buffer_store.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use crate::{
ProjectItem as _, ProjectPath,
ProjectPath,
lsp_store::OpenLspBufferHandle,
search::SearchQuery,
worktree_store::{WorktreeStore, WorktreeStoreEvent},
};
use anyhow::{Context as _, Result, anyhow};
use client::Client;
use collections::{HashMap, HashSet, hash_map};
use fs::Fs;
use futures::{Future, FutureExt as _, StreamExt, channel::oneshot, future::Shared};
use futures::{Future, FutureExt as _, channel::oneshot, future::Shared};
use gpui::{
App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Subscription, Task, WeakEntity,
};
Expand All @@ -23,8 +21,8 @@ use rpc::{
AnyProtoClient, ErrorCode, ErrorExt as _, TypedEnvelope,
proto::{self},
};
use smol::channel::Receiver;
use std::{io, pin::pin, sync::Arc, time::Instant};

use std::{io, sync::Arc, time::Instant};
use text::{BufferId, ReplicaId};
use util::{ResultExt as _, TryFutureExt, debug_panic, maybe, rel_path::RelPath};
use worktree::{File, PathChange, ProjectEntryId, Worktree, WorktreeId};
Expand Down Expand Up @@ -972,6 +970,10 @@ impl BufferStore {
.filter_map(|buffer| buffer.upgrade())
}

pub(crate) fn is_searchable(&self, id: &BufferId) -> bool {
!self.non_searchable_buffers.contains(&id)
}

pub fn loading_buffers(
&self,
) -> impl Iterator<Item = (&ProjectPath, impl Future<Output = Result<Entity<Buffer>>>)> {
Expand Down Expand Up @@ -1096,63 +1098,6 @@ impl BufferStore {
Some(())
}

pub fn find_search_candidates(
&mut self,
query: &SearchQuery,
mut limit: usize,
fs: Arc<dyn Fs>,
cx: &mut Context<Self>,
) -> Receiver<Entity<Buffer>> {
let (tx, rx) = smol::channel::unbounded();
let mut open_buffers = HashSet::default();
let mut unnamed_buffers = Vec::new();
for handle in self.buffers() {
let buffer = handle.read(cx);
if self.non_searchable_buffers.contains(&buffer.remote_id()) {
continue;
} else if let Some(entry_id) = buffer.entry_id(cx) {
open_buffers.insert(entry_id);
} else {
limit = limit.saturating_sub(1);
unnamed_buffers.push(handle)
};
}

const MAX_CONCURRENT_BUFFER_OPENS: usize = 64;
let project_paths_rx = self
.worktree_store
.update(cx, |worktree_store, cx| {
worktree_store.find_search_candidates(query.clone(), limit, open_buffers, fs, cx)
})
.chunks(MAX_CONCURRENT_BUFFER_OPENS);

cx.spawn(async move |this, cx| {
for buffer in unnamed_buffers {
tx.send(buffer).await.ok();
}

let mut project_paths_rx = pin!(project_paths_rx);
while let Some(project_paths) = project_paths_rx.next().await {
let buffers = this.update(cx, |this, cx| {
project_paths
.into_iter()
.map(|project_path| this.open_buffer(project_path, cx))
.collect::<Vec<_>>()
})?;
for buffer_task in buffers {
if let Some(buffer) = buffer_task.await.log_err()
&& tx.send(buffer).await.is_err()
{
return anyhow::Ok(());
}
}
}
anyhow::Ok(())
})
.detach();
rx
}

fn on_buffer_event(
&mut self,
buffer: Entity<Buffer>,
Expand Down
Loading
Loading