-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: fn_param completion lookup #12085
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
Conversation
@@ -56,7 +55,7 @@ fn fill_fn_params( | |||
ctx: &CompletionContext, | |||
function: &ast::Fn, | |||
param_list: &ast::ParamList, | |||
mut add_new_item_to_acc: impl FnMut(&str, String), | |||
mut add_new_item_to_acc: impl FnMut(&str), | |||
) { | |||
let mut file_params = FxHashMap::default(); |
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.
we still needs this to be a FxHashMap
for removing duplicates
let param = ctx.token.ancestors().find(|node| node.kind() == SyntaxKind::PARAM)?; | ||
|
||
let is_mut_token = (ctx.token.kind() == SyntaxKind::MUT_KW).then(|| &ctx.token); |
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.
I discovered this regression during testing: if current token is exactly mut
kw, for example fn foo(mut$0)
, the ancestor PARAM will include the R_PAREN and removes it incorrectly.
[crates/ide_completion/src/completions/fn_param.rs:160] ¶m = [email protected]
[email protected]
[email protected] "mut"
[email protected]
[email protected] ")"
I decided just to special case it but not sure if there are more situations the ancestor PARAM range should be adjusted.
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.
Oh that is a bug in the parser I am pretty sure. Iirc we have the invariant that nodes have balanced parentheses which isn't the case here
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.
So let's revert this special casing, as we should fix this in the parser instead, I'll look into that actually
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.
Should be fixed with #12090
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.
Thanks! I tried #12090 locally, while it fails the fuzz test("the parser seems stuck") it does fix this issue. I removed the kw test 5d63e7a#diff-52c63bea78a6963ad84e5744682632d05437285113ee1c1f3a5521e57518e111R597-R607 from previous commit as I think it'll be better to cover it in the parser.
Thanks! |
📌 Commit c1685e5 has been approved by |
☀️ Test successful - checks-actions |
close #12073 caused by #12040