-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add unwrap block assist #4156 #4207
Conversation
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
// } | ||
// ``` | ||
pub(crate) fn unwrap_block(ctx: AssistCtx) -> Option<Assist> { | ||
let res = if let Some(if_expr) = ctx.find_node_at_offset::<ast::IfExpr>() { |
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.
This will do a bunch of tree traversal. I think we should start the assist with let l_curly = ctx.find_token_at_offset(T!['{']);
and than look at it's parent up to certain depth, rather than the full set of ancestors.
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.
In generally, it doesn't make sense to worry to much about assist perf, but it's good to not do premature pessimization if possible
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 updated with your advices. But I didn't add a .take
method on ancestors iterator. Because it's a little bit subjective and I have no idea which limit we can set. You probably have a better idea so if you want to add this kind of limit let me know which limit I put.
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
bors r+ |
Build succeeded: |
close issue #4156