-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: add support for folding ranges for chained expressions #19659
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
base: master
Are you sure you want to change the base?
Conversation
|
I'm interested in the support for |
|
Currently, this feature only works on nvim, as it is the only editor that supports One of the nvim maintainers mentioned that syntax highlighting will be applied to collapsed text in the future, which enhancing its appearance. |
Veykril
left a comment
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 don't think this needs a config. This feels like something the client can expose as a config itself (as it is free to discard the collapsedText field instead of using it)
While it does not impact functionality, it may decrease both the computational load and the size of responses. |
|
I refactored the code in the new commit based on the previous review and simplified the implementation of |
|
any update on this? |
9cbf37f to
ed00c5d
Compare
ed00c5d to
08fe1e4
Compare
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.
Pull request overview
This PR adds support for folding ranges for chained expressions in rust-analyzer, addressing issue #19620. The implementation introduces collapsed text functionality that provides preview text when folding multi-line statements and tail expressions.
Key changes:
- Extended
FoldKindenum withStmtandTailExprvariants to support folding of statements and tail expressions - Added
collapsed_textfield toFoldstruct to provide preview text for folded regions - Implemented
collapse_exprfunction to generate preview text for chain method calls and other expressions - Added client capability detection for
folding_range.collapsed_textsupport
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/ide/src/folding_ranges.rs | Core implementation of statement/tail expression folding and collapsed text generation |
| crates/ide/src/lib.rs | Updated folding_ranges API signature to accept collapsed_text parameter |
| crates/ide/src/static_index.rs | Updated call to folding_ranges with new parameter |
| crates/rust-analyzer/src/handlers/request.rs | Added client capability check and passes flag to folding ranges computation |
| crates/rust-analyzer/src/lsp/capabilities.rs | Added method to detect client support for collapsed text in folding ranges |
| crates/rust-analyzer/src/lsp/to_proto.rs | Updated LSP protocol conversion to include collapsed text with proper indentation handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
08fe1e4 to
544ed92
Compare
Sorry, I've been busy finishing my master's thesis looking for a job recently. I have resolved the conflicts. @Veykril Do you have any suggestions? |




fix #19620.