microsoft / microsoft/language-server-protocol

More powerful folding ranges API

Open
#827 8 comments 5 reactions 1 assignee View on GitHub

@aeschli is already working on this.

Since Sep 24, 2019.

feature-request folding ranges
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:

image

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

image

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:

image

image

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

image

To implement these features, we need to add two things to the protocol:

  • a replacementText?: string field to FoldingRange (this covers bullet points 1 & 2)
  • add a group?: number field to FoldingRange, such that all ranges in the group are folded-unfolded in lockstep. This covers use case 3, 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.