Skip to content

Commit 9656ceb

Browse files
Document the feature
1 parent 19cfa58 commit 9656ceb

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

crates/completion/src/completions/unqualified_path.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,49 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T
7373
}
7474
}
7575

76+
// Feature: Fuzzy Completion and Autoimports
77+
//
78+
// When completing names in the current scope, proposes additional imports from other modules or crates,
79+
// if they can be qualified in the scope and their name contains all symbols from the completion input
80+
// (case-insensitive, in any order or places).
81+
//
82+
// ```
83+
// fn main() {
84+
// pda<|>
85+
// }
86+
// # pub mod std { pub mod marker { pub struct PhantomData { } } }
87+
// ```
88+
// ->
89+
// ```
90+
// use std::marker::PhantomData;
91+
//
92+
// fn main() {
93+
// PhantomData
94+
// }
95+
// # pub mod std { pub mod marker { pub struct PhantomData { } } }
96+
// ```
97+
//
98+
// .Fuzzy search details
99+
//
100+
// To avoid an excessive amount of the results returned, completion input is checked for inclusion in the identifiers only
101+
// (i.e. in `HashMap` in the `std::collections::HashMap` path), also not in the module indentifiers.
102+
//
103+
// .Merge Behaviour
104+
//
105+
// It is possible to configure how use-trees are merged with the `importMergeBehaviour` setting.
106+
// Mimics the corresponding behaviour of the `Auto Import` feature.
107+
//
108+
// .LSP and performance implications
109+
//
110+
// LSP 3.16 provides the way to defer the computation of some completion data, including the import edits for this feature.
111+
// If the LSP client supports the `additionalTextEdits` (case sensitive) resolve client capability, rust-analyzer computes
112+
// the completion edits only when a corresponding completion item is selected.
113+
// For clients with no such support, all edits have to be calculated on the completion request, including the fuzzy search completion ones,
114+
// which might be slow.
115+
//
116+
// .Feature toggle
117+
//
118+
// The feature can be turned off in the settings with the `rust-analyzer.completion.enableExperimental` flag.
76119
fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
77120
let _p = profile::span("fuzzy_completion");
78121
let current_module = ctx.scope.module()?;

0 commit comments

Comments
 (0)