Add support for lineFoldingOnly folding ranges #80955
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes dotnet/vscode-csharp#7974
Unblocks #80944 (comment)
VSCode sets the lineFoldingOnly LSP capability, indicating it cannot handle multiple folding ranges that start on the same line as another range starts or ends on. Folding ranges that are not compatible are simply dropped.
While we cannot always do anything more than drop one of the ranges, we can choose which range to drop and we can sometimes adjust ranges so that they will not be dropped:
This is done as a post processing step of the ranges. This seemed reasonable as the service generally independently constructs folding ranges based on the syntax and has little knowledge of what the other ranges will be produced (to know if they overlap)