dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.13k stars 4.04k forks source link

Pressing enter key when creating switch expression forces variable and braces on 1 line #70294

Open vsfeedback opened 1 year ago

vsfeedback commented 1 year ago

This issue has been moved from a ticket on Developer Community.


[regression] [worked-in:17.4.4] When creating a switch expression for an enum and typing the open/beginning brace, a set of curly braces are created which is correct, but it puts those on the same line. Then if you press the enter key, it forces the switched variable to be on the same line, instead of creating a new line. See animated .gif. In the .gif, after it creates the braces and shows intellisense, it looks as if I selected "custodianType" from intellisense, but I didn't. I only pressed the enter key.

BadSwitchExpression


Original Comments

Feedback Bot on 10/3/2023, 02:22 AM:

(private comment, text removed)


Original Solutions

(no solutions)

sharwell commented 1 year ago

The enum name should not be hard-selected prior to typing a character in this scenario.

Dean-NC commented 1 year ago

@arkalyanms I'm the original poster of the ticket referenced at the top. This same issue happens with typing a semi-colon for CSS in .cshtml, which also didn't happen in 17.4.4 and started after that. In this case (see animated .gif) I'm typing line-height and when providing the value of 1.3, intellisense hard-selects the first choice so that when I type a semi-colon, the intellisense choice gets forced into the code.

It seems to be related to the C# issue.

TypeSemicolon