Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#9,804 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp, typescript, vscode

Direzione di ricerca

Look at the C# extension's auto-insert handler registration, likely in the TypeScript source. The issue mentions a registerOnAutoInsert handler that processes { and newline. Find where this handler is defined and how it reads VS Code settings like editor.autoClosingBrackets and editor.formatOnType. Test changes by disabling the handler's brace insertion when those settings are 'never' and false. Verify the fix works with C# Dev Kit enabled and doesn't break other formatting.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Editor-Formatting Resolved-Configuration Issue

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.

Lingua principale
TypeScript
Stelle
3.1k
Fork
736
Merge medio
21h 21m
PR unite (30g)
42

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnet/vscode-csharp

Tutte le issue di dotnet/vscode-csharp

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.