Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d5fb7a4

Browse files
committed
Limit number of completions
1 parent ec89fc8 commit d5fb7a4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

crates/rust-analyzer/src/to_proto.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,19 @@ pub(crate) fn completion_items(
215215
let max_relevance = items.iter().map(|it| it.relevance().score()).max().unwrap_or_default();
216216
let mut res = Vec::with_capacity(items.len());
217217
for item in items {
218-
completion_item(&mut res, config, line_index, &tdpp, max_relevance, item)
218+
completion_item(&mut res, config, line_index, &tdpp, max_relevance, item);
219+
220+
if let Some(limit) = config.completion().limit {
221+
if res.len() >= limit {
222+
break;
223+
}
224+
}
219225
}
226+
227+
if let Some(limit) = config.completion().limit {
228+
res.truncate(limit);
229+
}
230+
220231
res
221232
}
222233

0 commit comments

Comments
 (0)