diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-01-12 11:37:18 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-12 11:37:18 +0000 |
| commit | de50ef4bea467c18c42ecb66e240340cd3e181fa (patch) | |
| tree | ae281baf019e344ebc55f7689d9d81632c169616 | |
| parent | 54782428a621b996f1bbcc133e3d6a008db762b5 (diff) | |
| parent | 314b199e3c2d69a8c4818bc439aa6df9081a2aa6 (diff) | |
| download | rust-de50ef4bea467c18c42ecb66e240340cd3e181fa.tar.gz rust-de50ef4bea467c18c42ecb66e240340cd3e181fa.zip | |
Merge #11263
11263: fix: Fix don't drop param completions when fully typing out a pattern r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
| -rw-r--r-- | crates/ide_completion/src/completions/fn_param.rs | 12 | ||||
| -rw-r--r-- | crates/ide_completion/src/tests/pattern.rs | 14 |
2 files changed, 23 insertions, 3 deletions
diff --git a/crates/ide_completion/src/completions/fn_param.rs b/crates/ide_completion/src/completions/fn_param.rs index bb4ce0a24dc..a55bab67e11 100644 --- a/crates/ide_completion/src/completions/fn_param.rs +++ b/crates/ide_completion/src/completions/fn_param.rs @@ -83,9 +83,15 @@ fn remove_duplicated( let whole_param = param.syntax().text().to_string(); file_params.remove(&whole_param); - if let Some(pattern) = param.pat() { - let binding = pattern.syntax().text().to_string(); - file_params.retain(|_, v| v != &binding); + match param.pat() { + // remove suggestions for patterns that already exist + // if the type is missing we are checking the current param to be completed + // in which case this would find itself removing the suggestions due to itself + Some(pattern) if param.ty().is_some() => { + let binding = pattern.syntax().text().to_string(); + file_params.retain(|_, v| v != &binding); + } + _ => (), } }) } diff --git a/crates/ide_completion/src/tests/pattern.rs b/crates/ide_completion/src/tests/pattern.rs index c9a31eea849..7f437e1a077 100644 --- a/crates/ide_completion/src/tests/pattern.rs +++ b/crates/ide_completion/src/tests/pattern.rs @@ -368,3 +368,17 @@ fn foo() { "#]], ) } + +#[test] +fn completes_fully_equal() { + check_empty( + r#" +fn foo(bar: u32) {} +fn bar(bar$0) {} +"#, + expect![[r#" + bn bar: u32 + kw mut + "#]], + ) +} |
