From 0d61377adeb96546b008ef064eec2266c274ee5d Mon Sep 17 00:00:00 2001 From: Ankita Khera <40616383+akhera99@users.noreply.github.com> Date: Wed, 13 Sep 2023 15:00:30 -0700 Subject: [PATCH] Fix folding range bug in C# extension (#69817) * fix folding range bug * feedback * folding range works for regions now --- .../Handler/FoldingRanges/FoldingRangesHandler.cs | 10 +++++++++- .../FoldingRanges/FoldingRangesTests.cs | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Features/LanguageServer/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs b/src/Features/LanguageServer/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs index e211bc1ad7b54..50b7dc2b0c304 100644 --- a/src/Features/LanguageServer/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs @@ -41,7 +41,15 @@ public FoldingRangesHandler(IGlobalOptionService globalOptions) if (document is null) return null; - var options = _globalOptions.GetBlockStructureOptions(document.Project); + var options = _globalOptions.GetBlockStructureOptions(document.Project) with + { + // Need to set the block structure guide options to true since the concept does not exist in vscode + // but we still want to categorize them as the correct BlockType. + ShowBlockStructureGuidesForCommentsAndPreprocessorRegions = true, + ShowBlockStructureGuidesForDeclarationLevelConstructs = true, + ShowBlockStructureGuidesForCodeLevelConstructs = true + }; + return await GetFoldingRangesAsync(document, options, cancellationToken).ConfigureAwait(false); } diff --git a/src/Features/LanguageServer/ProtocolUnitTests/FoldingRanges/FoldingRangesTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/FoldingRanges/FoldingRangesTests.cs index 1e2cfcc2651ca..d994b0aabdf56 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/FoldingRanges/FoldingRangesTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/FoldingRanges/FoldingRangesTests.cs @@ -52,7 +52,7 @@ public async Task TestGetFoldingRangeAsync_Comments(bool mutatingLspWorkspace) AssertJsonEquals(expected, results); } - [Theory(Skip = "GetFoldingRangeAsync does not yet support regions."), CombinatorialData] + [Theory, CombinatorialData] public async Task TestGetFoldingRangeAsync_Regions(bool mutatingLspWorkspace) { var markup =