在 Visual Studio C# 编辑器中关闭“智能分号”

Bry*_*ner 6 visual-studio

在 Visual Studio 2019 中,当您点击分号时,它喜欢尝试猜测应该将分号放在哪里。通常它会跳转到完全不同的行或插入换行符。每当它执行除了将其附加为下一个字符之外的任何操作时,这都是极具破坏性的,我必须返回并修复它所破坏的内容。这类似于破坏性的“自动大括号完成”,它总是将大括号放在我不想要的地方,但可以关闭。我找不到任何地方可以关闭分号行为。有什么办法可以关闭这个功能吗?

大多数时候,分号出现问题是因为我误按了它,但我现在没有按退格键,而是有更大的混乱需要清理。我从来没有遇到过它做了我想要它做的额外事情的情况。

一些示例,其中 * 是光标位置:

// between a ) and ; 
Foo()*;
// inserts an extra space
Foo();* ;

// before an existing semicolon:
return null*;
// moves the old semicolon to the next line:
return null;*
;

// pressing semicolon in the middle of a multi-line function call:
string path = Path.Combine(
    "C:\\",
    "b"*
    "filename.txt");
// moves the cursor to the end of the block and inserts a "; " before ";":
string path = Path.Combine(
    "C:\\",
    "b"
    "filename.txt");* ;
Run Code Online (Sandbox Code Playgroud)

Bry*_*ner 5

Visual Studio 16.10 添加了一个新的配置选项来控制这一点:

文本编辑器 -> C# -> Intellisense -> 自动完成分号语句

通过检查,我得到了问题中描述的有问题的行为。当我取消选中该选项时,它会像以前一样工作。