-
Notifications
You must be signed in to change notification settings - Fork 1.8k
parameter completion are no longer being filtered by the client #12073
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
Comments
@Veykril Sorry but I think this bug was introduced in #12040. Sadly, I still get the By changing the
btw, the test below will produce the full list even before that PR. Is there a way to test the filtering? #[test]
fn filter_param() {
check(
r#"
fn foo(foo: u32, bar: u32, baz: u32, qux: u32, ) {}
fn bar(b$0)
}
"#,
expect![[r#"
bn qux: u32
bn foo: u32
bn baz: u32
bn bar: u32
kw ref
kw mut
"#]],
);
} I think it'll be a good idea to enforce the filtering in tests as #12040 (comment) said? |
The completion item docs for the lsp layer are here https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItem Specifically our Sp the lookup string has to contain the identifier that is being completed. Though I am not sure how this plays out with non identifier characters being in there and the docs don't say anything about it so that might be VSCode playing wrong as well.
We should probably add asserts in tests to check for LSP conformance there. |
The cause of the filtering issue is
Just remove the lookup in the edit: The original lookup in |
Ah the the filter text is set to the parameter that we complete, yes that would explain the weird filtering here. I don't quite see how the original lookup doesn't work though. Or rather I am not sure why the lookup had to be changed at all. |
|
I guess one easy fix would be to append the completion to the contents of what the completion text range covers and use that as the lookup? Not too fond of it but that seems like the simplest approach |
Given following code as an example: fn f(foo: (), #[baz = "qux"] mut bar: u32) {}
fn g(foo: ()#[baz = "qux"] mut ba$0)
I'm not very sure about why this would be better than using the label itself. |
Ah right, I misunderstood, ye the label itself is enough (in which case you can just drop the |
Whether including the type or not is a different decision. Params without type (e.g Another (unrelated) question I had about the completions for fn params is, rust-analyzer/crates/ide_completion/src/completions/fn_param.rs Lines 33 to 36 in 198c075
In which situation would we hit the |
From a quick glance, never. It's just that we want to avoid unwraps so we use some defaults in these cases even if they won't be hit. |
I was asking this as if we use the label as lookup and very unlikely to hit the |
Ye we don't need to I think |
shows all the parameters here, but the client should be able to filter all but

bar
andbaz
out.The text was updated successfully, but these errors were encountered: