mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
typing underscore should not trigger completions in types or patterns
This commit is contained in:
parent
f19479a2ad
commit
ae5d74dffb
2 changed files with 131 additions and 0 deletions
|
@ -169,6 +169,28 @@ pub fn completions(
|
|||
return Some(completions.into());
|
||||
}
|
||||
|
||||
// when the user types a bare `_` (that is it does not belong to an identifier)
|
||||
// the user might just wanted to type a `_` for type inference or pattern discarding
|
||||
// so try to suppress completions in those cases
|
||||
if trigger_character == Some('_') && ctx.original_token.kind() == syntax::SyntaxKind::UNDERSCORE
|
||||
{
|
||||
if let CompletionAnalysis::NameRef(NameRefContext {
|
||||
kind:
|
||||
NameRefKind::Path(
|
||||
path_ctx @ PathCompletionCtx {
|
||||
kind: PathKind::Type { .. } | PathKind::Pat { .. },
|
||||
..
|
||||
},
|
||||
),
|
||||
..
|
||||
}) = analysis
|
||||
{
|
||||
if path_ctx.is_trivial_path() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
let acc = &mut completions;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue