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
18.7k stars 3.98k forks source link

Typing a quote character after `new` inserts two quotes. #74162

Open vsfeedback opened 1 week ago

vsfeedback commented 1 week ago

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


[severity:It's more difficult to complete my work] [regression] [worked-in:17.8] because i have to fight against it, all the time, i needed to disable the feature. Three things need to happen to make it usable, again: 1) configure the different types of braces / quotes that should be completed automatically.


Original Comments

Feedback Bot on 3/11/2024, 07:22 PM:

(private comment, text removed)

Alisa Qu [MSFT] on 3/13/2024, 01:16 AM:

(private comment, text removed)

Alexander Gayko on 4/2/2024, 07:04 AM:

(private comment, text removed)

Feedback Bot on 3/19/2024, 10:28 PM:

(private comment, text removed)

Alisa Qu [MSFT] on 4/2/2024, 07:39 PM:

(private comment, text removed)


Original Solutions

(no solutions)

CyrusNajmabadi commented 1 week ago

this is def an odd case. It's unclear to me why inserting open/quote at the same time here is bad. Presumably if a string is being written here, it's going to need its close brace. Would need the user to indicate why that's actually undesirable here.

CyrusNajmabadi commented 1 week ago

if i have them configured to be in separate lines, please put the closing one at the proper place (and put the opening one with the caret there, too, if possible.

Note: we don't have settings for braces to be on separate lines. What we have is a setting about where the opening and closing braces should go if it is a multi-line construct. We always allow (and attempt to preserve) braces on hte same line if that's what the user wants for a particular construct.

So our model here is to emit as {} as that allows for the latter common form. Then, if the user hits enter within that, we update the braces to be in the right location for either setting of the formatting option.