fixed bug limiting number of results returned

This commit is contained in:
KCaverly 2023-09-26 10:29:55 -04:00
commit 330a71d28b
44 changed files with 1818 additions and 369 deletions

View file

@ -456,7 +456,7 @@ fn main() {
let languages = Arc::new(languages);
let node_runtime = RealNodeRuntime::new(http.clone());
languages::init(languages.clone(), node_runtime.clone());
languages::init(languages.clone(), node_runtime.clone(), cx);
language::init(cx);
project::Project::init(&client, cx);

View file

@ -820,14 +820,9 @@ impl SemanticIndex {
let batch_results = futures::future::join_all(batch_results).await;
let mut results = Vec::new();
let mut min_similarity = None;
for batch_result in batch_results {
if batch_result.is_ok() {
for (id, similarity) in batch_result.unwrap() {
if min_similarity.map_or_else(|| false, |min_sim| min_sim > similarity) {
continue;
}
let ix = match results
.binary_search_by_key(&Reverse(similarity), |(_, s)| Reverse(*s))
{
@ -835,11 +830,8 @@ impl SemanticIndex {
Err(ix) => ix,
};
if ix <= limit {
min_similarity = Some(similarity);
results.insert(ix, (id, similarity));
results.truncate(limit);
}
results.insert(ix, (id, similarity));
results.truncate(limit);
}
}
}