diff options
| author | Maria José Solano <majosolano99@gmail.com> | 2023-01-19 18:23:21 -0800 |
|---|---|---|
| committer | Maria José Solano <majosolano99@gmail.com> | 2023-01-19 18:23:21 -0800 |
| commit | d5fb7a4ba4abf638e293d872b8767a206922e995 (patch) | |
| tree | ee2757d453356e3a1d8b43d0135a5755ed59d835 | |
| parent | ec89fc85a84b0529156782b77311b208e1531c47 (diff) | |
| download | rust-d5fb7a4ba4abf638e293d872b8767a206922e995.tar.gz rust-d5fb7a4ba4abf638e293d872b8767a206922e995.zip | |
Limit number of completions
| -rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 0f0642bb4b5..f5cee5f907a 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -215,8 +215,19 @@ pub(crate) fn completion_items( let max_relevance = items.iter().map(|it| it.relevance().score()).max().unwrap_or_default(); let mut res = Vec::with_capacity(items.len()); for item in items { - completion_item(&mut res, config, line_index, &tdpp, max_relevance, item) + completion_item(&mut res, config, line_index, &tdpp, max_relevance, item); + + if let Some(limit) = config.completion().limit { + if res.len() >= limit { + break; + } + } } + + if let Some(limit) = config.completion().limit { + res.truncate(limit); + } + res } |
