Skip to content

Commit 21adceb

Browse files
committed
Optionally disable term search for autocompletion
1 parent ef2aed8 commit 21adceb

File tree

7 files changed

+23
-0
lines changed

7 files changed

+23
-0
lines changed

crates/ide-completion/src/completions/expr.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,11 @@ pub(crate) fn complete_expr_path(
331331

332332
pub(crate) fn complete_expr(acc: &mut Completions, ctx: &CompletionContext<'_>) {
333333
let _p = profile::span("complete_expr");
334+
335+
if !ctx.config.enable_term_search {
336+
return;
337+
}
338+
334339
if !ctx.qualifier_ctx.none() {
335340
return;
336341
}

crates/ide-completion/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct CompletionConfig {
1414
pub enable_imports_on_the_fly: bool,
1515
pub enable_self_on_the_fly: bool,
1616
pub enable_private_editable: bool,
17+
pub enable_term_search: bool,
1718
pub full_function_signatures: bool,
1819
pub callable: Option<CallableSnippets>,
1920
pub snippet_cap: Option<SnippetCap>,

crates/ide-completion/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig {
6565
enable_imports_on_the_fly: true,
6666
enable_self_on_the_fly: true,
6767
enable_private_editable: false,
68+
enable_term_search: true,
6869
full_function_signatures: false,
6970
callable: Some(CallableSnippets::FillArguments),
7071
snippet_cap: SnippetCap::new(true),

crates/rust-analyzer/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ config_data! {
282282
"scope": "expr"
283283
}
284284
}"#,
285+
/// Whether to enable term search based snippets like `Some(foo.bar().baz())`.
286+
completion_term_search_enable: bool = "true",
285287

286288
/// List of rust-analyzer diagnostics to disable.
287289
diagnostics_disabled: FxHashSet<String> = "[]",
@@ -1517,6 +1519,7 @@ impl Config {
15171519
&& completion_item_edit_resolve(&self.caps),
15181520
enable_self_on_the_fly: self.data.completion_autoself_enable,
15191521
enable_private_editable: self.data.completion_privateEditable_enable,
1522+
enable_term_search: self.data.completion_term_search_enable,
15201523
full_function_signatures: self.data.completion_fullFunctionSignatures_enable,
15211524
callable: match self.data.completion_callable_snippets {
15221525
CallableCompletionDef::FillArguments => Some(CallableSnippets::FillArguments),

crates/rust-analyzer/src/integrated_benchmarks.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ fn integrated_completion_benchmark() {
132132
enable_imports_on_the_fly: true,
133133
enable_self_on_the_fly: true,
134134
enable_private_editable: true,
135+
enable_term_search: true,
135136
full_function_signatures: false,
136137
callable: Some(CallableSnippets::FillArguments),
137138
snippet_cap: SnippetCap::new(true),
@@ -176,6 +177,7 @@ fn integrated_completion_benchmark() {
176177
enable_imports_on_the_fly: true,
177178
enable_self_on_the_fly: true,
178179
enable_private_editable: true,
180+
enable_term_search: true,
179181
full_function_signatures: false,
180182
callable: Some(CallableSnippets::FillArguments),
181183
snippet_cap: SnippetCap::new(true),
@@ -217,6 +219,7 @@ fn integrated_completion_benchmark() {
217219
enable_imports_on_the_fly: true,
218220
enable_self_on_the_fly: true,
219221
enable_private_editable: true,
222+
enable_term_search: true,
220223
full_function_signatures: false,
221224
callable: Some(CallableSnippets::FillArguments),
222225
snippet_cap: SnippetCap::new(true),

docs/user/generated_config.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ Default:
337337
----
338338
Custom completion snippets.
339339

340+
--
341+
[[rust-analyzer.completion.term.search.enable]]rust-analyzer.completion.term.search.enable (default: `true`)::
342+
+
343+
--
344+
Whether to enable term search based snippets like `Some(foo.bar().baz())`.
340345
--
341346
[[rust-analyzer.diagnostics.disabled]]rust-analyzer.diagnostics.disabled (default: `[]`)::
342347
+

editors/code/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,11 @@
897897
},
898898
"type": "object"
899899
},
900+
"rust-analyzer.completion.term.search.enable": {
901+
"markdownDescription": "Whether to enable term search based snippets like `Some(foo.bar().baz())`.",
902+
"default": true,
903+
"type": "boolean"
904+
},
900905
"rust-analyzer.diagnostics.disabled": {
901906
"markdownDescription": "List of rust-analyzer diagnostics to disable.",
902907
"default": [],

0 commit comments

Comments
 (0)