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>
This commit is contained in:
bors[bot] 2022-01-12 11:37:18 +00:00 committed by GitHub
commit de50ef4bea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View File

@ -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);
}
_ => (),
}
})
}

View File

@ -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
"#]],
)
}