-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add ParameterListStructureProvider for collapsing multi-line parameter lists #80944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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. |
|
@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. |
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 😆
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. |
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) 
Co-authored-by: dibarbet <[email protected]>
Co-authored-by: dibarbet <[email protected]>
daa1d90 to
d4812e6
Compare
| 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; |
There was a problem hiding this comment.
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.

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 fromAbstractSyntaxNodeStructureProvider<ParameterListSyntax>that enables collapsing when the opening(and closing)span 2+ linesCSharpBlockStructureProvider.cs: RegisteredParameterListStructureProviderin the node provider mapParameterListSyntaxStructureTests.cs: Test coverage for methods, constructors, delegates, lambdas, anonymous methods, and local functionsExample
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/8725curl -s REDACTED(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.