Open just-ero opened 1 week ago
@just-ero Something seems off about your C# extension version. The closest I can find to 1.14.2 is 1.14.0 published back in 2018. The Roslyn Formatter that ships with that version of the extension predates collection expressions.
Thanks for the heads up. That was the version of the C# DevKit extension. I've fixed my mistake.
@just-ero Thanks for updating! I can reproduce your issue and will move it to the Roslyn repo.
The body of the method is indented 8 spaces and when the formatter deindents those lines to 4 spaces, it fails to deindent the line with the closing square bracket. The same code without the trailing comma formats as expected.
CC: @CyrusNajmabadi
I don't repro this in VS @JoeRobich . Do you? Is there a full repro for this?
@CyrusNajmabadi These are the step I used to reproduce it.
For VS Code I followed these steps:
void M()
{
int[] arr =
[
0,
];
}
VS Code: https://github.com/user-attachments/assets/abf3d9f2-5062-4211-b94d-adb858cdbcb5
Doing similar in VS also reproduces the problem:
VS: https://github.com/user-attachments/assets/ca727ce1-5a43-400f-bd62-05e0bdc7c5e7
Retitled the issue as formatOnSave
is not necessary to reproduce the issue. Also, I have no idea why my videos are links instead of being embedded.
Environment data
VS Code version: 1.95.2,
e8653663e8840adaf45af01eab5c627a5af81807
, x64C# Extension version: v2.56.31
Steps to reproduce
editor.formatOnSave
is enabled.Expected behavior
Actual behavior