mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
fix: Fix don't drop param completions when fully typing out a pattern
This commit is contained in:
parent
a3393c9a57
commit
314b199e3c
2 changed files with 23 additions and 3 deletions
|
@ -83,9 +83,15 @@ fn remove_duplicated(
|
||||||
let whole_param = param.syntax().text().to_string();
|
let whole_param = param.syntax().text().to_string();
|
||||||
file_params.remove(&whole_param);
|
file_params.remove(&whole_param);
|
||||||
|
|
||||||
if let Some(pattern) = param.pat() {
|
match param.pat() {
|
||||||
let binding = pattern.syntax().text().to_string();
|
// remove suggestions for patterns that already exist
|
||||||
file_params.retain(|_, v| v != &binding);
|
// 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);
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
"#]],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue