Skip to content

C# Dev Kit auto-insert ignores editor.autoClosingBrackets and editor.formatOnType #9804

Description

@andrewfender

Summary

With C# Dev Kit enabled, typing { and pressing Enter in a C# file automatically inserts/indents a closing } and moves the opening { to its own line.

This happens despite C# auto-closing and format-on-type being explicitly disabled.

Disabling C# Dev Kit stops the behavior, but Visual Studio Tools for Unity depends on C# Dev Kit.

Environment

  • VS Code: 1.139.0
  • C# Dev Kit: 3.40.204
  • C#: 2.160.4
  • .NET Install Tool: 3.2.0
  • Visual Studio Tools for Unity: 1.3.1
  • OS: Windows

Relevant VS Code settings

"editor.autoClosingBrackets": "never",
"editor.autoIndent": "keep",
"editor.formatOnType": false,
"[csharp]": {
  "editor.formatOnType": false,
  "editor.formatOnSave": false,
  "editor.formatOnPaste": false,
  "editor.autoClosingBrackets": "never"
},
"csharp.format.enable": false

Relevant .editorconfig settings

[*.cs]
csharp_new_line_before_open_brace = none
csharp_indent_braces = false

Steps to reproduce

  1. Enable C# Dev Kit.
  2. Open a .cs file in a loaded solution.
  3. Type void Foo() { and press Enter.

Expected behavior

The opening brace remains on the same line, no closing brace is inserted, and normal indentation is preserved:

void Foo() {
    |

Actual behavior

Roslyn inserts/reformats braces:

void Foo()
{
    |
}

Isolation performed

  • Reloading VS Code with extensions disabled stops the behavior.
  • Disabling C# Dev Kit alone stops the behavior.
  • The C# extension’s registerOnAutoInsert handler processes { and newline changes independently of editor.autoClosingBrackets and editor.formatOnType.
  • Filtering { and newline from that handler locally fixes the issue while keeping C# Dev Kit and Visual Studio Tools for Unity enabled.

Requested behavior

Please make Roslyn auto-insert honor:

  • editor.autoClosingBrackets: "never"
  • editor.formatOnType: false

Alternatively, please add a user setting that disables Roslyn auto-insert for braces and newlines.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions