Skip to content

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

Description

With microsoft/typescript-go#2772 (b81c7e9), we added support for lineFoldingOnly clients by consistently backing off a line; however, having a trailing } for every outlining span feels kind of unnecessary.

microsoft/vscode#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   | } <EOF>

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

Activity

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

Metadata

Metadata

Labels

Domain: LS: OutliningRelates to multi-line regions that editors can collapseExperimentation NeededSomeone needs to try this out to see what happensSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions