Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#9,804 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp, typescript, vscode

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
3.1k
Fork
738
Merge trung bình
21 giờ 21 phút
Pull request đã merge (30 ngày)
42

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/vscode-csharp

Tất cả issue của dotnet/vscode-csharp

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.