Roslyn: Smart indent should handle braces when brace completion and formatting are disabled

Created on 26 Oct 2018  路  4Comments  路  Source: dotnet/roslyn

Version Used: 15.8.8

Steps to Reproduce:

  1. Set indentation mode to Smart
  2. Disable Automatic Brace Completion
  3. Disable formatting while typing
  4. Type if (true)
  5. Press Enter
  6. Type {

Expected Behavior:

if (true)
{

Actual Behavior:

if (true)
    {

Notes:

The tests for this feature should also cover the case where the steps above are followed by:

  1. Press Enter
  2. Press }

:link: Derived from information in https://developercommunity.visualstudio.com/content/problem/49738/c-braces-indent-incorrectly-if-brace-completion-is.html

Area-IDE Bug Developer Community Resolution-Fixed

Most helpful comment

I'm taking a look at this.

All 4 comments

This is so annoying, so either we use the semi retarded brace completion or live with that weird indentation issue once it's disabled. I hope this gets fixed soon.

A work around for this is to enable Automatically Format when Typing in the settings and check both Format on ; and format on }.

@pushqrdx This is marked 'help wanted'. It would be great if you were interested in this if you could help out with a fix. Thanks!

Note: from looking at teh above, this seems by-design. Smart indent indents properly when you press 'enter'. it puts you here:

c# if (whatever) $

You also asked to disable 'format when typing'. So, when you type { formatting is definitely not going and formatting that item, as per the intent.

--

One thing i can think about here would be to have a 'automatically format on {' so that you can turn off most formatting, but have the formatter place { in the right location when you typed it. Otherwise, it's unclear to me how this would be expected to work since hte option to actually format code as you type is was explicitly disabled.

I'm taking a look at this.

Was this page helpful?
0 / 5 - 0 ratings