防止 VS Code 在 Enter 时更改缩进

bas*_*kum 1 visual-studio-code

假设我有一个包含以下内容的 JavaScript 文件,并且光标位于管道符号 ( |) 处:

class ItemCtrl {
    getPropertiesByItemId(id) {
        return this.fetchItem(id)
            .then(item => {
                return this.getPropertiesOfItem(item);
            });
    }|
}
Run Code Online (Sandbox Code Playgroud)

如果我现在按 Enter,代码会按以下方式更改:

class ItemCtrl {
    getPropertiesByItemId(id) {
        return this.fetchItem(id)
            .then(item => {
                return this.getPropertiesOfItem(item);
            });
        }
        |
}
Run Code Online (Sandbox Code Playgroud)

当它应该与方法定义对齐时,它错误地将右花括号与 return 语句对齐。我知道函数内部的格式不是最好的,但我仍然宁愿禁用该功能以防止发生类似的奇怪事情。

我已经设置了editor.autoIndentfalse但它仍然会发生。有没有其他方法,我如何完全关闭此功能?(或使其以更智能的方式工作)

Mat*_*ner 5

在 VS Code 1.17 中,此错误导致"editor.autoIndent": false无法正常工作

这应该在 VS Code 1.18 中修复