Omnisharp-vscode: Opening brace not moved to new line while typing

Created on 12 Jun 2018  路  3Comments  路  Source: OmniSharp/omnisharp-vscode

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.300
 Commit:    adab45bf0c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.300\

Host (useful for support):
  Version: 2.1.0
  Commit:  caa7b7e2ba

.NET Core SDKs installed:
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.300 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

VS Code version: 1.24.0

C# Extension version: 1.15.2

Steps to reproduce

Type a class, such as public class Testing { }

Expected behavior

In most editors, after typing the opening brace, a closing brace is automatically added. Some editors choose to format at this point, moving the opening brace to its own line and the closing brace to its own line, and placing the cursor on a blank line between them automatically indented.

Actual behavior

Upon pressing enter, the opening brace remains on the same line as the declaration, the closing brace is moved to its own line, and the cursor is placed on a blank line between them, like so:

public class Testing {
    |
}

I have tried creating the omnisharp.json file in %USERPROFILE%\.omnisharp\ with the desired settings, but it does not seem to have an impact. Format on typing is enabled in VS Code. Typing something like public bool Test {get;set;} gets formatted to public bool Test { get; set; } automatically. Manually triggering formatting through the right click context menu formats opening braces to their own line as desired, so it shouldn't be a configuration issue. The formatting is just not applied while typing.

Bug Editor-Formatting Resolved-Duplicate

Most helpful comment

@akshita31 : Note that there is a "Resolved-Duplicate" label that you can use to mark issues as dupes when closing.

All 3 comments

Thanks for reporting this. I can definitely reproduce this issue.

Closing this as a duplicate of #1591

@akshita31 : Note that there is a "Resolved-Duplicate" label that you can use to mark issues as dupes when closing.

Was this page helpful?
0 / 5 - 0 ratings