Skip to content

feat: support folding multiline arg list & fn body in one folding range #20054

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

Merged
merged 3 commits into from
Jul 10, 2025

Conversation

Young-Flash
Copy link
Member

@Young-Flash Young-Flash commented Jun 21, 2025

It would be convenient to just one-click fold arg list and func body(TypeScript does). However, this behavior is inconsistent with now, perhaps we need a configurable setting that allows users to customize it?

PixPin_2025-06-30_17-30-39-20250630173048-rlibom6

close #19299

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 21, 2025
Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I don't think the previous behavior is useful enough to warrant a setting, but maybe someone disagrees? @rust-lang/rust-analyzer

Also, can you please add a test?

@Veykril
Copy link
Member

Veykril commented Jun 24, 2025

I'd love if we could support both at the same time, that is if editors (VSCode ...) were smarter to be honest, generally I do agree when someone folds a function they want to fold the function, not the signature in the vast majority of cases.

I wonder if we can either hook this in the typescript side to combine the folding ranges (probably needs heuristics which sound bad), or if we can emit the current behavior but also a full function fold and see what happens (as in how clients deal with that).

Either way +1 for having this do the expected thing by default somehow.

@roife
Copy link
Member

roife commented Jun 30, 2025

It would be very interesting to utilize collapsed_text (see #19659) when folding param lists! Of course, it can be implemented in the future PR.

For example, even though we have folded the entire fn, we can still display a "simplified parameter list" using collapsed_text.

@Young-Flash
Copy link
Member Author

have no idea why CI failed

@rustbot ready

@ShoyuVanilla
Copy link
Member

The failing test is a flaky one(#20220) so I think this is good to go

@ShoyuVanilla ShoyuVanilla enabled auto-merge July 10, 2025 11:54
@ShoyuVanilla
Copy link
Member

@ChayimFriedman2 I think the requested changes have been handled. Could you resolve the request?

@ShoyuVanilla ShoyuVanilla added this pull request to the merge queue Jul 10, 2025
@ChayimFriedman2
Copy link
Contributor

FWIW I don't think the request blocks merging, but I approved now.

Merged via the queue into rust-lang:master with commit 600f573 Jul 10, 2025
41 of 45 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 10, 2025
@ShoyuVanilla
Copy link
Member

Thanks! I'm not sure whether this was blocked or not but GitHub's UI said so 😅

@Young-Flash
Copy link
Member Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function folding body with head
6 participants