Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

ep: Cap identifiers for LSP context retriever (#58539)

Oleksiy Syvokon569511a1a341
diff --git a/crates/edit_prediction_context/src/edit_prediction_context.rs b/crates/edit_prediction_context/src/edit_prediction_context.rs
index 97a1729ec64..f8706006dcf 100644
--- a/crates/edit_prediction_context/src/edit_prediction_context.rs
+++ b/crates/edit_prediction_context/src/edit_prediction_context.rs
@@ -34,6 +34,7 @@ pub use editable_context::{
pub use zeta_prompt::{ContextSource, RelatedExcerpt, RelatedFile};
const IDENTIFIER_LINE_COUNT: u32 = 3;
+const MAX_CONTEXT_IDENTIFIER_COUNT: usize = 32;
pub struct RelatedExcerptStore {
project: WeakEntity<Project>,
@@ -259,6 +260,7 @@ impl RelatedExcerptStore {
})
.collect();
identifiers_with_distance.sort_by_key(|(_, distance)| *distance);
+ identifiers_with_distance.truncate(MAX_CONTEXT_IDENTIFIER_COUNT);
let mut cursor_distances: HashMap<Identifier, usize> = HashMap::default();
let mut current_rank = 0;