microsoft / microsoft/TypeScript

Include terminating line in folding ranges when last token has no trailing non-trivia

Ouverte
#64,235 0 commentaires 0 réactions 1 personne assignée Voir sur GitHub

@gabritto y travaille déjà.

Depuis le 10/9/2026.

Domain: LS: Outlining Experimentation Needed Suggestion
Langage dominant
Go
Étoiles
111k
Forks
14.3k
Merge moyen
2 j 4 h
PR mergées (30 j)
132

Description

With https://github.com/microsoft/typescript-go/pull/2772 (b81c7e9afd7f1e0b2ec2ac1fd581e09fe00df1af), we added support for `lineFoldingOnly` clients by consistently backing off a line; however, having a trailing `}` for every outlining span feels kind of unnecessary.

https://github.com/microsoft/vscode/issues/3352 has a lot of feedback, so maybe we can find a compromise. We discussed this a bit at #334371.

Instead of always backing off at these brace characters, maybe we should determine whether the terminating line has any non-trivia.

In other words...

### `else` on line following `}`:

```
A-START | if (Math.random()) {
|
A-END | }
B-START | else if (Math.random()) {
|
B-END | }
```

### `else` on same line as `}`:

```
A-START | if (Math.random()) {
A-END |
B-START | } else if (Math.random()) {
|
B-END | }
```

### Statement on same line as `}`

```
A-START | if (Math.random()) {
A-END |
| } /*strange, but valid*/ console.log("hi there what're you doin' on this line?")
```

### Contents on lines following `}`

```
A-START | if (Math.random()) {
|
A-END | }
| /* Normal - this is totally normal code! That is why I am saying so! */
| console.log("Hello world!");
```

### Empty statement on same line as `}`

This one is odd, and maybe even undesirable - but I anticipate the implementation will be cleaner without any special-cases.

```
A-START | if (Math.random()) {
A-END |
| };
```

### Comment on same line as `}`

```
A-START | if (Math.random()) {
|
A-END | } // finally out of that `if`
```

### End-of-file is on the same line as `}`

```
A-START | if (Math.random()) {
|
A-END | }
```

Should ensure that we have a test where EOF is on the same line and it works fine.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.