-
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
Extract into function assist sometimes strips comments #13621
Comments
Hey @jplatte 👋 I was exploring this issue and trying to replicate it, but when I tried: pub fn hello() {
for _ in 0..1 {
$0// Extract the following condition with this comment
if true {
continue;
}$0
if false {
break;
}
}
} with this selection I couldn't find any code actions available, same when I added this as a test case, code action of |
Here's a failing test case: #13692 |
Heyo 👋, Thanks for the failing test case, I see the difference between mine and yours was I had I see you created a draft PR, so I would guess you are already working it? Lemme know if that's not the case, I will pick it up then only :) |
I just made it a PR so it's archived in a nice way (PRs survive deletion of the branch or even the whole repo). I'm not working on it. |
Makes sense, thanks for the clarification! 🙇 |
fix: make make_body respect comments in extract_function Possible fix for #13621 ### Points to help in review: - Earlier we were only considering statements in a block expr and hence comments were being ignored, now we handle tokens hence making it aware of comments and then preserving them using `hacky_block_expr_with_comments` Seems like I am not able to attach output video, github is glitching for it :(
The previously failing test was included on #13746 and passes now, so I'll close this. |
I tried:
and got
when it should have been
See also #13620 which is potentially related.
rust-analyzer version:
rust-analyzer version: 0.4.1286-standalone
rustc version:
rustc 1.65.0 (897e37553 2022-11-02)
relevant settings: -
The text was updated successfully, but these errors were encountered: