-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: Improve parameter completion #12040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -562,6 +562,90 @@ fn qux(Foo { bar }: Foo) { | |
fn main() { | ||
qux(${1:foo})$0 | ||
} | ||
"#, | ||
); | ||
} | ||
|
||
#[test] | ||
fn complete_fn_param() { | ||
// has mut kw | ||
check_edit( | ||
"mut ba", | ||
r#" | ||
fn f(foo: (), mut bar: u32) {} | ||
fn g(foo: (), mut ba$0) | ||
"#, | ||
r#" | ||
fn f(foo: (), mut bar: u32) {} | ||
fn g(foo: (), mut bar: u32) | ||
"#, | ||
); | ||
|
||
// has type param | ||
check_edit( | ||
"mut ba: u32", | ||
r#" | ||
fn g(foo: (), mut ba$0: u32) | ||
fn f(foo: (), mut bar: u32) {} | ||
"#, | ||
r#" | ||
fn g(foo: (), mut bar: u32) | ||
fn f(foo: (), mut bar: u32) {} | ||
"#, | ||
); | ||
} | ||
|
||
#[test] | ||
fn complete_fn_mut_param_add_comma() { | ||
// add leading and trailing comma | ||
check_edit( | ||
", mut ba", | ||
r#" | ||
fn f(foo: (), mut bar: u32) {} | ||
fn g(foo: ()mut ba$0 baz: ()) | ||
"#, | ||
r#" | ||
fn f(foo: (), mut bar: u32) {} | ||
fn g(foo: (), mut bar: u32, baz: ()) | ||
"#, | ||
); | ||
} | ||
|
||
#[test] | ||
fn complete_fn_mut_param_has_attribute() { | ||
check_edit( | ||
"mut ba", | ||
r#" | ||
fn f(foo: (), #[baz = "qux"] mut bar: u32) {} | ||
fn g(foo: (), mut ba$0) | ||
Comment on lines
+619
to
+620
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests pass for both completion listing and edit, but doesn't work on my machine, not sure what's wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be the same bug that I fixed in #11967 - basically, the completion's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly, 8f8f20f should fix this? At least it became working in my environment. |
||
"#, | ||
r#" | ||
fn f(foo: (), #[baz = "qux"] mut bar: u32) {} | ||
fn g(foo: (), #[baz = "qux"] mut bar: u32) | ||
"#, | ||
); | ||
|
||
check_edit( | ||
r#"#[baz = "qux"] mut ba"#, | ||
r#" | ||
fn f(foo: (), #[baz = "qux"] mut bar: u32) {} | ||
fn g(foo: (), #[baz = "qux"] mut ba$0) | ||
"#, | ||
r#" | ||
fn f(foo: (), #[baz = "qux"] mut bar: u32) {} | ||
fn g(foo: (), #[baz = "qux"] mut bar: u32) | ||
"#, | ||
); | ||
|
||
check_edit( | ||
r#", #[baz = "qux"] mut ba"#, | ||
r#" | ||
fn f(foo: (), #[baz = "qux"] mut bar: u32) {} | ||
fn g(foo: ()#[baz = "qux"] mut ba$0) | ||
"#, | ||
r#" | ||
fn f(foo: (), #[baz = "qux"] mut bar: u32) {} | ||
fn g(foo: (), #[baz = "qux"] mut bar: u32) | ||
"#, | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only when editor's insert mode set to
replace
? Is there a way to test edit results with lsp cap and editor settings? Not seems possible withCompletionConfig
yet