Skip to content

Conversation

@roife
Copy link
Member

@roife roife commented Apr 22, 2025

fix #19620.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 22, 2025
@roife roife marked this pull request as draft April 22, 2025 03:08
@roife
Copy link
Member Author

roife commented Apr 22, 2025

I'm interested in the support for collapsed_text, so I will convert this to a draft PR for now.

@roife
Copy link
Member Author

roife commented Jun 30, 2025

I have finished a prototype:

image

If we fold the line let navs...

image


image image

@roife roife marked this pull request as ready for review June 30, 2025 05:17
@roife roife force-pushed the fold-chained-expr branch from 5d9ecd0 to b7936e6 Compare June 30, 2025 05:30
@roife
Copy link
Member Author

roife commented Jun 30, 2025

Currently, this feature only works on nvim, as it is the only editor that supports collapsed_text.

One of the nvim maintainers mentioned that syntax highlighting will be applied to collapsed text in the future, which enhancing its appearance.

@roife roife force-pushed the fold-chained-expr branch from b7936e6 to 6fd1271 Compare June 30, 2025 06:19
Copy link
Member

@Veykril Veykril left a 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)

@roife
Copy link
Member Author

roife commented Jun 30, 2025

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.

@roife
Copy link
Member Author

roife commented Jun 30, 2025

I refactored the code in the new commit based on the previous review and simplified the implementation of build_fold.

@Young-Flash
Copy link
Member

any update on this?

@roife roife force-pushed the fold-chained-expr branch from 9cbf37f to ed00c5d Compare January 8, 2026 09:08
Copilot AI review requested due to automatic review settings January 8, 2026 09:08
@roife roife force-pushed the fold-chained-expr branch from ed00c5d to 08fe1e4 Compare January 8, 2026 09:10
Copy link

Copilot AI left a 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 FoldKind enum with Stmt and TailExpr variants to support folding of statements and tail expressions
  • Added collapsed_text field to Fold struct to provide preview text for folded regions
  • Implemented collapse_expr function to generate preview text for chain method calls and other expressions
  • Added client capability detection for folding_range.collapsed_text support

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.

@roife roife force-pushed the fold-chained-expr branch from 08fe1e4 to 544ed92 Compare January 8, 2026 09:24
@roife
Copy link
Member Author

roife commented Jan 8, 2026

any update on this?

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collapsible chained expressions (Method and Field Chains)

4 participants