Skip to content

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

Open

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

  1. dibarbet commented on Sep 23, 2026

    @dibarbet
    Member

    To disable this behavior, turn off dotnet.autoInsert.enableAutoInsert

  2. andrewfender commented on Sep 23, 2026

    @andrewfender
    Author

    @dibarbet That is not an ideal solution, as it disables various other auto-formatting/auto-insert behaviours that are desireable. Auto-completion/auto-formatting of braces should be configurable independently (and were, until very recently - this issue only arose for me since yesterday).

  3. dibarbet commented on Sep 23, 2026

    @dibarbet
    Member

    Hmm I can't reproduce this:

    Image

    Are you able to share your project at all? Can you run the csdevkit.collectLogs with these settings, and reproduce the issue under the recording?
    Image

  4. andrewfender commented on Sep 23, 2026

    @andrewfender
    Author

    csdevkit-logs-2026-09-23T21-47-46.zip

    CSTest.zip

    2026-09-23.22-47-12.mp4

    I reproduced it here with an empty project. I've attached the logs and the project.

  5. dibarbet commented on Sep 23, 2026

    @dibarbet
    Member

    @andrewfender thanks for the logs and details! At least from your latest repro, this is happening because you just have a C# file open with no context on what project it belongs to. C# files need to be part of a project, or have directives indicating it's a standalone file based app. See this for more details - https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/#file-based-apps-vs-project-based-apps

    Without those, the extension treats the file as a 'Miscellaneous File' and generally runs in a degraded state. In this state the .editorconfig is not applied. The C# language status bar will indicate you're in this state by the 'Miscellaenous Files' label:
    Image

    I noticed you might be using Unity - Unity should be generating the project (.csproj) for you, though I believe some setup in Unity is required.

  6. andrewfender commented on Sep 24, 2026

    @andrewfender
    Author
    2026-09-24.07-50-44.mp4

    csdevkit-logs-2026-09-24T06-51-13.zip
    TestProject.zip

    Reproduced in an empty Unity project, as shown here. Attached the C# Dev Kit logs and the project itself (excluding Library).

    (The opening brace being moved to a new line seems to not happen every time. I can't determine the exact steps or context that determines whether it happens or not. The closing brace being moved & indented does happen every time.)

    Just to reiterate that this issue only arose within the last 2 days; I've never seen it happen before with Unity. It feels very much like a recent extension update issue, although from what I see none of my extensions have been updated that recently (and I already tried rolling back various extensions to their second-latest versions).

  7. andrewfender commented on Oct 20, 2026

    @andrewfender
    Author

    Bump. This is labelled "Resolved-Configuration Issue", but there doesn't seem to be a configuration that fixes this particular problem. The only config that was suggested is to disable dotnet.autoInsert.enableAutoInsert, but doing so turns off all auto-insert behaviour, not just this particular case. Again, this is an issue that only started recently - enableAutoInsert was turned on before without this issue happening.

    My previous comment shows a repro of the issue in a fresh project with Assembly-CSharp as the active context, so it isn't an issue with no project context as suggested above.

    Can this issue be reopened?

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