Un serialize project search (#2857)

This is the first batch of improvements to current project search. There
are few things we can do better still, but I want to get this out in
next Preview.
Most of the slowness at this point seems to stem from updating UI too
often.

Release Notes:
- Improved project search by making it report results sooner.

---------

Co-authored-by: Julia Risley <julia@zed.dev>
This commit is contained in:
Piotr Osiewicz 2023-08-26 01:31:52 +02:00 committed by GitHub
parent 104f5ae9cd
commit 2495d6581e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 489 additions and 300 deletions

View file

@ -3953,11 +3953,12 @@ async fn search(
query: SearchQuery,
cx: &mut gpui::TestAppContext,
) -> Result<HashMap<String, Vec<Range<usize>>>> {
let results = project
.update(cx, |project, cx| project.search(query, cx))
.await?;
Ok(results
let mut search_rx = project.update(cx, |project, cx| project.search(query, cx));
let mut result = HashMap::default();
while let Some((buffer, range)) = search_rx.next().await {
result.entry(buffer).or_insert(range);
}
Ok(result
.into_iter()
.map(|(buffer, ranges)| {
buffer.read_with(cx, |buffer, _| {