Add support for lineFoldingOnly folding ranges#80955
Merged
dibarbet merged 4 commits intodotnet:mainfrom Oct 30, 2025
Merged
Conversation
dibarbet
commented
Oct 30, 2025
src/Tools/ExternalAccess/Razor/Features/Cohost/Handlers/FoldingRanges.cs
Outdated
Show resolved
Hide resolved
davidwengier
approved these changes
Oct 30, 2025
src/Tools/ExternalAccess/Razor/Features/Cohost/Handlers/FoldingRanges.cs
Outdated
Show resolved
Hide resolved
This was referenced Nov 1, 2025
davidwengier
added a commit
to dotnet/razor
that referenced
this pull request
Nov 3, 2025
Three things I've been tracking from Roslyn: 1. Auto insert support for raw string literals: dotnet/roslyn#80871 2. Line Folding Only support in VS Code: dotnet/roslyn#80955 (fixes #12414) * We already did this in our folding range response anyway 3. Allow FormattingLogTest can use real types, and remove our temporary equivalent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)