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

Commit ec89fc8

Browse files
committed
Add limit setting
1 parent 6e52c64 commit ec89fc8

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

crates/ide-completion/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub struct CompletionConfig {
1919
pub insert_use: InsertUseConfig,
2020
pub prefer_no_std: bool,
2121
pub snippets: Vec<Snippet>,
22+
pub limit: Option<usize>
2223
}
2324

2425
#[derive(Clone, Debug, PartialEq, Eq)]

crates/ide-completion/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig {
7575
skip_glob_imports: true,
7676
},
7777
snippets: Vec::new(),
78+
limit: None,
7879
};
7980

8081
pub(crate) fn completion_list(ra_fixture: &str) -> String {

crates/rust-analyzer/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ config_data! {
199199
completion_postfix_enable: bool = "true",
200200
/// Enables completions of private items and fields that are defined in the current workspace even if they are not visible at the current position.
201201
completion_privateEditable_enable: bool = "false",
202+
/// Maximum number of completions to return. If `None`, the limit is infinite.
203+
completion_limit: Option<usize> = "null",
202204
/// Custom completion snippets.
203205
// NOTE: Keep this list in sync with the feature docs of user snippets.
204206
completion_snippets_custom: FxHashMap<String, SnippetDef> = r#"{
@@ -1313,6 +1315,7 @@ impl Config {
13131315
.snippet_support?
13141316
)),
13151317
snippets: self.snippets.clone(),
1318+
limit: self.data.completion_limit,
13161319
}
13171320
}
13181321

crates/rust-analyzer/src/integrated_benchmarks.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ fn integrated_completion_benchmark() {
146146
},
147147
snippets: Vec::new(),
148148
prefer_no_std: false,
149+
limit: None
149150
};
150151
let position =
151152
FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };
@@ -184,6 +185,7 @@ fn integrated_completion_benchmark() {
184185
},
185186
snippets: Vec::new(),
186187
prefer_no_std: false,
188+
limit: None
187189
};
188190
let position =
189191
FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };

0 commit comments

Comments
 (0)