Skip to content

Commit de50ef4

Browse files
bors[bot]Veykril
andauthored
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 <[email protected]>
2 parents 5478242 + 314b199 commit de50ef4

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

crates/ide_completion/src/completions/fn_param.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,15 @@ fn remove_duplicated(
8383
let whole_param = param.syntax().text().to_string();
8484
file_params.remove(&whole_param);
8585

86-
if let Some(pattern) = param.pat() {
87-
let binding = pattern.syntax().text().to_string();
88-
file_params.retain(|_, v| v != &binding);
86+
match param.pat() {
87+
// remove suggestions for patterns that already exist
88+
// if the type is missing we are checking the current param to be completed
89+
// in which case this would find itself removing the suggestions due to itself
90+
Some(pattern) if param.ty().is_some() => {
91+
let binding = pattern.syntax().text().to_string();
92+
file_params.retain(|_, v| v != &binding);
93+
}
94+
_ => (),
8995
}
9096
})
9197
}

crates/ide_completion/src/tests/pattern.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,17 @@ fn foo() {
368368
"#]],
369369
)
370370
}
371+
372+
#[test]
373+
fn completes_fully_equal() {
374+
check_empty(
375+
r#"
376+
fn foo(bar: u32) {}
377+
fn bar(bar$0) {}
378+
"#,
379+
expect![[r#"
380+
bn bar: u32
381+
kw mut
382+
"#]],
383+
)
384+
}

0 commit comments

Comments
 (0)