Skip to content
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

Support folding range groups and "hoist to single line"-folding ranges #1932

Open
nthykier opened this issue May 4, 2024 · 0 comments
Open
Assignees
Labels
feature-request Request for new features or functionality folding ranges
Milestone

Comments

@nthykier
Copy link

nthykier commented May 4, 2024

Hi

Like #1779, I would like to see improvements to the folding range support. However, I decided to file this one a a separate issue, because it would need more than defining more folding range kinds.

I would also very much like to see the "hoist small function to single line"-folding range. As an example, JetBrains IDE supports folding

   public void setFoo(String foo) {
      this.foo = foo;
   }

into:

   public void setFoo(String foo) { this.foo = foo; }

In the JetBrains IDE, this is done by emitting two folding ranges. The first for the start brace and one for the end brace and their related whitespace (notably the newline). In this example, marked by [...] ranges with the original content inside the [...].

   public void setFoo(String foo)[ { \n         ]this.foo = foo;[\n   }]

The two folding ranges are then defined to related, so that the editor knows that that should expand/fold at the same time. The "two range" approach could have been replaced by a single range. However, the folding range text is not rendered as code. That is, syntax highlighting is lost. I think that would equally be true for most LSP clients since the collapsedText attribute is defined as text (and not stylish-able code - also, even then, it would be a layer violation for the folding range code to figure out how to highlight one line of code, no matter if it is in the server or the client).

This "two range"-mode example shown above would require the client to announce FoldingRangeClientCapabilities.lineFoldingOnly=false to be possible (making the dependency explicit).

@dbaeumer dbaeumer added feature-request Request for new features or functionality folding ranges labels May 6, 2024
@dbaeumer dbaeumer added this to the Backlog milestone May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality folding ranges
Projects
None yet
Development

No branches or pull requests

3 participants