Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

Implements collapsing/expanding for multi-line parameter lists in VS Code and other Roslyn-powered editors, matching the existing behavior of ArgumentListStructureProvider.

Resolves #80946

Changes

  • ParameterListStructureProvider.cs: New provider inheriting from AbstractSyntaxNodeStructureProvider<ParameterListSyntax> that enables collapsing when the opening ( and closing ) span 2+ lines
  • CSharpBlockStructureProvider.cs: Registered ParameterListStructureProvider in the node provider map
  • ParameterListSyntaxStructureTests.cs: Test coverage for methods, constructors, delegates, lambdas, anonymous methods, and local functions

Example

// Collapsible (line difference >= 2)
void ProcessData(
    string inputFile,
    string outputFile,
    bool validateData)
{
    // Can collapse to: void ProcessData(...)
}

// Not collapsible (line difference < 2)
void ProcessData(string inputFile,
    string outputFile)
{
    // No collapse indicator shown
}

Fixes https://github.com/dotnet/vscode-csharp/issues/8725

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/dotnet/vscode-csharp/issues/8725
    • Triggering command: curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Please resolve https://github.com/dotnet/vscode-csharp/issues/8725 by implementing a new ParameterListStructureProvider (likely inheriting from AbstractSyntaxNodeStructureProvider) and adding it to the list in CSharpBlockStructureProvider. Similar to the ArgumentListStructureProvider, only provide the structure if the parameter list is greater than or equal to 2 lines.

Please add tests for this as well. Look at ArgumentListSyntaxStructureTests for examples of existing tests.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add parameter list structure provider with tests Add ParameterListStructureProvider for collapsing multi-line parameter lists Oct 28, 2025
Copilot AI requested a review from dibarbet October 28, 2025 23:20
Copilot finished work on behalf of dibarbet October 28, 2025 23:20
@dibarbet
Copy link
Member

dibarbet commented Oct 29, 2025

seems fine, but actually worsens the VSCode experience due to dotnet/vscode-csharp#7974 - causes the method folding ranges to disappear and you only get the parameter list range.

that needs to be fixed first before this can go in. leaving as draft for now.

@lonix1
Copy link

lonix1 commented Oct 29, 2025

@dibarbet Thanks for taking a stab at this. I hope it can be completed when the blocker is removed.

One question: was the Copilot bot responsible for crafting the entire PR? That is absolutely mind boggling if true.

@dibarbet
Copy link
Member

I hope it can be completed when the blocker is removed.

I am working on this, but it's definitely a bit more complicated. Our folding range providers aren't really designed to not have overlapping lines 😆

One question: was the Copilot bot responsible for crafting the entire PR? That is absolutely mind boggling if true.

It was indeed. It did a pretty good job on this one, I don't think I'll have to fix much here. You can see the specific prompt in the PR description under 'Original prompt' if you are curious.

dibarbet added a commit that referenced this pull request Oct 30, 2025
Fixes dotnet/vscode-csharp#7974
Unblocks
#80944 (comment)

VSCode sets the
[lineFoldingOnly](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#foldingRangeClientCapabilities)
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:
1. If two ranges start on the same line, we want to pick the inner range
for folding.
2. If a range ends on the same line as another starts, we can attempt to
shrink it by one line to handle common cases like an else block starting
on the same line as the if block ended:
```
if (blah) {
    ...
} else {
    ...
}
```

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)


![folding_ranges_overlap](https://github.com/user-attachments/assets/8c712443-faea-4d9d-a59d-1bb456860740)
@dibarbet dibarbet force-pushed the copilot/add-parameter-list-structure-provider branch from daa1d90 to d4812e6 Compare October 30, 2025 20:21
@dibarbet
Copy link
Member

Unfortunately in VSCode we can't make the experience perfect. The folding range for the method starts on the same line that the parameter folding range would end, and VSCode does not allow this overlap. So the parameter range gets shrunk by one, leading to the last parameter line being unfolded.

parameter_folding_range

@dibarbet dibarbet marked this pull request as ready for review November 4, 2025 21:41
@dibarbet dibarbet requested a review from a team as a code owner November 4, 2025 21:41
var text = node.SyntaxTree.GetText(cancellationToken);
var start = text.Lines.GetLinePosition(openToken.SpanStart).Line;
var end = text.Lines.GetLinePosition(closeToken.SpanStart).Line;
return end - start >= 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatted offline about the >= 2 and it matches the behavior of the argument list provider.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: folding multiline method signatures

4 participants