microsoft / microsoft/language-server-protocol
More powerful folding ranges API
@aeschli is already working on this.
Since Sep 24, 2019.
- Dominant language
- TypeScript
- Stars
- 13k
- Forks
- 1k
- Avg merge
- 6d 1h
- Merged PRs (30d)
- 10
Description
When VS Code folds the range, it just completely hides its contents:

When IntelliJ folds the range, it shows a certain replacement string instead:

The latter behavior is more flexible, and it would be cool if the protocol supported it. It allows for the following features:
-
folding a subrange in the string, which allows to hide boilerplate (see this post for example)
-
folded blocks take one line instead of two:


- showing some important info from the fold, without making it more verbose:

To implement these features, we need to add two things to the protocol:
- a
replacementText?: stringfield toFoldingRange(this covers bullet points 1 & 2) - add a
group?: numberfield toFoldingRange, such that all ranges in the group are folded-unfolded in lockstep. This covers use case3, where{and}are separate folding ranges, linked into one group
However, I assume that the bulk of work here needs to happen on the editor's side as it seems like VS Code doesn't support such replacements yet.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.