fix(completions): improve fn_param

- insert commas around when necessary
- only suggest `self` completions when param list is empty
- stop suggesting completions for identifiers which are already on the param list
This commit is contained in:
Eduardo Canellas 2022-01-04 15:03:46 -03:00
parent dbb1c1b4b1
commit a9612666f8
2 changed files with 75 additions and 24 deletions

View file

@ -46,7 +46,20 @@ fn bar(file_id: usize) {}
fn baz(file$0 id: u32) {}
"#,
expect![[r#"
bn file_id: usize
bn file_id: usize,
kw mut
"#]],
);
}
#[test]
fn repeated_param_name() {
check(
r#"
fn foo(file_id: usize) {}
fn bar(file_id: u32, $0) {}
"#,
expect![[r#"
kw mut
"#]],
);
@ -126,7 +139,6 @@ impl A {
#[test]
fn in_impl_after_self() {
// FIXME: self completions should not be here
check(
r#"
struct A {}
@ -137,10 +149,6 @@ impl A {
}
"#,
expect![[r#"
bn self
bn &self
bn mut self
bn &mut self
bn file_id: usize
kw mut
sp Self